Skip to content

demo(07-magic-connection-string): 07 — Hardcoded SQL connection string in Program.cs#146

Closed
EricCogen wants to merge 1 commit intomainfrom
demo/07-magic-connection-string
Closed

demo(07-magic-connection-string): 07 — Hardcoded SQL connection string in Program.cs#146
EricCogen wants to merge 1 commit intomainfrom
demo/07-magic-connection-string

Conversation

@EricCogen
Copy link
Copy Markdown
Owner

07 — Hardcoded SQL connection string in Program.cs

Expected verdict: ❌ Fails — GauntletCI should fire GCI0010 (hardcoded connection string).

What changed

src/OrderService/Program.cs registers an order-database connection string
as a constant directly in code, instead of binding it from IConfiguration:

// Order-database connection — temporarily inlined while the
// secret-store wiring is being moved out of the legacy host.
const string ordersDbConnection =
    "Server=tcp:orders-db.internal;Database=Orders;Integrated Security=true;TrustServerCertificate=true";
builder.Services.AddSingleton(new OrdersDbConnectionString(ordersDbConnection));

The literal contains the canonical Server= connection-string marker,
which GauntletCI's GCI0010 rule recognises as an environment-coupled
configuration value baked into source.

Why this is risky

  • A connection string in source ties the binary to one environment —
    promoting the same artefact to staging or production now requires a
    rebuild.
  • Even when the literal carries no password (as here), the host name
    leaks internal infrastructure topology into every artifact and CI log.
  • It removes the ability to rotate the endpoint without a code change,
    which is exactly what configuration is for.

What GauntletCI catches

GCI0010 Hardcoding and Configuration — string literal containing a
Server= connection-string marker added to a non-test file.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GauntletCI found the following issues:

These findings reference lines outside the PR diff, so they appear here instead of inline. Expand each entry for full evidence, rationale, and suggested action.

GCI0010 — Hardcoding and Configuration (`src/OrderService/Program.cs`): Hardcoded connection string detected.

GCI0010 — Hardcoding and Configuration

Hardcoded connection string detected.

Evidence:

Line 27: "Server=tcp:orders-db.internal;Database=Orders;Integrated Security=true;TrustServerCertificate=true";

⚠️ Why it matters: Connection strings in source code expose credentials and prevent per-environment configuration.

💡 Suggested action: Use IConfiguration, Secret Manager, or environment variables for connection strings.

Confidence: High | Severity: Block

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e30d535e3d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +26 to +27
const string ordersDbConnection =
"Server=tcp:orders-db.internal;Database=Orders;Integrated Security=true;TrustServerCertificate=true";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Move order DB connection string out of source code

Hardcoding ordersDbConnection here bakes an environment-specific SQL endpoint into the binary, so the same build cannot be safely promoted across environments without rebuilding, and it exposes internal infrastructure details in source/artifacts; this should be loaded from configuration or a secret provider at runtime instead of a string literal in Program.cs.

Useful? React with 👍 / 👎.

…g in Program.cs

See scenarios/07-magic-connection-string/README.md for the expected verdict.
@EricCogen
Copy link
Copy Markdown
Owner Author

Reopening with refreshed scenario.

@EricCogen EricCogen force-pushed the demo/07-magic-connection-string branch from e30d535 to cfa8177 Compare April 27, 2026 08:36
@EricCogen EricCogen closed this Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant