Skip to content

fix(ci): SonarCloud analysis scope and Postgres analysis - #3914

Open
pflynn-virtru wants to merge 2 commits into
mainfrom
fix/sonarcloud-quality-gate-config
Open

fix(ci): SonarCloud analysis scope and Postgres analysis #3914
pflynn-virtru wants to merge 2 commits into
mainfrom
fix/sonarcloud-quality-gate-config

Conversation

@pflynn-virtru

@pflynn-virtru pflynn-virtru commented Aug 24, 2026

Copy link
Copy Markdown
Member

Proposed Changes

SonarCloud's quality gate has been failing on main, so every commit gets a red X. The workflow itself is green — it's the gate check that fails. Most of what it was counting wasn't real.

Every .sql file was being analyzed as Oracle PL/SQL. sonar.plsql.file.suffixes defaults to sql,pks,pkb, while the PostgreSQL analyzer's default (pgsql,psql) matched nothing we have. Our SQL is Postgres, and Oracle's parser choked on 19 of our 48 migrations — which is why three were flagged as DELETE missing a WHERE when they actually rewrite a table from a temp table. This points .sql at the analyzer that can read it.

Test fixtures were being scanned as production source. Excluding test/** and **/testdata/** stops the recurring "leaked secret" findings from bats harnesses, a JWT that expired in 2019, and sample private keys — the ones we keep hand-triaging as won't fix.

sonar.scm.disabled is gone. It only existed because the gitignored coverage report was being indexed as source; excluding coverage.* removes the need. Sonar can date lines from git blame again.

Also bumps sonarqube-scan-action v6.0.0 → v8.2.1. We were two majors behind, and v6 runs node20, which GitHub is deprecating and already warns about in our logs.

Validation

Verified by temporarily enabling pull_request and a branch-scoped push trigger, then reverting. Both runs succeeded:

  • PR scan — confirms the mechanics
  • Branch scan — confirms findings, since PR scans only see changed files
Before After
SQL findings 148 (PL/SQL) 0 (PostgreSQL)
Migrations failing to parse 19 of 48 0 of 62
coverage.json indexed as source yes no
SCM disabled active

Worth knowing: the PostgreSQL analyzer has 12 rules to PL/SQL's 186, so some of that 148 → 0 is lost breadth. Still the right trade — 131 of the 148 were one noise rule (duplicated string literals, mostly on sqlc query files) and 3 were BLOCKER bugs that were simply wrong. Notably postgresdre:S2260 ("Postgres files should not have syntax errors") fired zero times, confirming all 62 files now parse cleanly.

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

n/a — CI configuration only, no Go code changed.

Testing Instructions

No Go changed, so make lint / make test don't apply. See the two runs linked above.

Once merged, workflow_dispatch makes on-demand scans possible (GitHub only exposes the trigger once it's on the default branch):

gh workflow run sonarcloud.yml --repo opentdf/platform

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • SonarCloud analysis can now be started manually.
    • Updated the SonarCloud scanning action for improved compatibility.
    • Refined code-quality analysis settings to exclude tests, test data, and coverage files.
    • Added support for analyzing PL/SQL and PostgreSQL files.

@github-actions github-actions Bot added the comp:ci Github Actions Work label Aug 24, 2026
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 52 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 58ad7268-7643-4729-a656-bc54328db474

📥 Commits

Reviewing files that changed from the base of the PR and between 0ef046e and bbc3e7a.

📒 Files selected for processing (2)
  • .github/workflows/sonarcloud.yml
  • sonar-project.properties
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sonarcloud-quality-gate-config

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 256.283066ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 134.271169ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 438.096531ms
Throughput 228.26 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 44.071043138s
Average Latency 439.961032ms
Throughput 113.45 requests/second

@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 247.950971ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 132.100683ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 439.401938ms
Throughput 227.58 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 46.056186938s
Average Latency 459.744192ms
Throughput 108.56 requests/second

The SonarQube Cloud quality gate fails on main, putting a red X on every
commit. Most of what it is counting is not real.

Every .sql file was being analyzed by the Oracle PL/SQL analyzer, because
sonar.plsql.file.suffixes defaults to "sql,pks,pkb" while
sonar.postgres.file.suffixes defaults to "pgsql,psql" and so matched
nothing we have. Our SQL is PostgreSQL: 26 of 48 migrations use SERIAL,
JSONB, RETURNING, ON CONFLICT or gen_random_uuid, and 8 use $$-quoted
function bodies that Oracle has no concept of. 19 of the 48 migrations
fail to parse under the Oracle grammar, which is why three of them are
reported as DELETE statements missing a WHERE clause when in fact they
rewrite a whole table from a temp table.

Of the 148 plsql findings, 131 are S1192 "define a constant instead of
duplicating this literal", and 96 of all findings sit in
service/policy/db/queries, which are sqlc query definitions where
repeating a column name is unavoidable and constants do not exist.

Point .sql at the analyzer that can parse it.

Also exclude test scaffolding from production-source analysis. test/**
and **/testdata/** hold bats harnesses and fixtures such as a JWT that
expired in 2019 and sample private keys; scanning them as production
source is what produces the recurring "leaked secret" findings we keep
hand-triaging as won't fix.

Excluding coverage.* means the gitignored coverage report is no longer
indexed as a source file, which the scan log shows happening today
("Cannot parse 'coverage.json:2:1'"). That was the only reason SCM was
disabled, so sonar.scm.disabled can be dropped and Sonar can date lines
from git blame again.

Signed-off-by: Paul Flynn <pflynn-virtru@users.noreply.github.com>
We were two majors behind. v8.2.1 runs on node24 (v6 runs node20, which
GitHub is deprecating and already warns about in our scan logs) and ships
SonarScanner CLI 8.1.0.6389 instead of 7.2.0.5079.

v8.0.0 flipped skipSignatureVerification to false, so scanner binaries are
now GPG-verified by default. v8.2.1 includes the fix for signature
verification failing when the temp directory path is too long.

Drop-in: the action has no required inputs and we pass none, only the
SONAR_TOKEN and GITHUB_TOKEN env vars. The dependency-review allowlist
entry for this action is version-agnostic.

Add workflow_dispatch so scans can be run on demand instead of only on the
Tue/Thu/Sat cron.

Signed-off-by: Paul Flynn <pflynn-virtru@users.noreply.github.com>
@pflynn-virtru
pflynn-virtru force-pushed the fix/sonarcloud-quality-gate-config branch from 888a063 to bbc3e7a Compare August 24, 2026 15:58
@github-actions

Copy link
Copy Markdown
Contributor

pflynn-virtru added a commit that referenced this pull request Aug 24, 2026
Do not merge this commit. It exists so PR #3914 scans itself and we can
confirm the PL/SQL -> PostgreSQL analyzer switch behaves as expected
before the config change lands.

workflow_dispatch cannot be used for this: GitHub only exposes a workflow
for manual dispatch once the trigger is present on the default branch, so
on-demand runs are unavailable until this PR merges.

Revert before taking the PR out of draft.

Signed-off-by: Paul Flynn <pflynn-virtru@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 233.11844ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 138.877951ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 425.731ms
Throughput 234.89 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 43.81918026s
Average Latency 437.162311ms
Throughput 114.11 requests/second

@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 140.465149ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 80.092319ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 282.215129ms
Throughput 354.34 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 31.316137789s
Average Latency 312.599795ms
Throughput 159.66 requests/second

pflynn-virtru added a commit that referenced this pull request Aug 24, 2026
…rCloud

Do not merge this commit. It exists so PR #3914 scans itself and we can
confirm the PL/SQL -> PostgreSQL analyzer switch behaves as expected
before the config change lands.

The push trigger is scoped to this branch and forces a full branch
analysis. A pull_request scan cannot answer the question on its own: its
sensors are restricted to changed files, and this PR changes no .sql, so
the PostgreSQL analyzer has nothing to look at and reports no findings.

workflow_dispatch cannot be used either: GitHub only exposes a workflow for
manual dispatch once the trigger is present on the default branch, so
on-demand runs are unavailable until this PR merges.

Revert before taking the PR out of draft.

Signed-off-by: Paul Flynn <pflynn-virtru@users.noreply.github.com>
@pflynn-virtru
pflynn-virtru force-pushed the fix/sonarcloud-quality-gate-config branch from 0179236 to d15e9de Compare August 24, 2026 16:20
@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 232.472393ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 136.280808ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 424.385837ms
Throughput 235.63 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 44.185186128s
Average Latency 441.101094ms
Throughput 113.16 requests/second

@sonarqubecloud

Copy link
Copy Markdown

@pflynn-virtru
pflynn-virtru force-pushed the fix/sonarcloud-quality-gate-config branch from d15e9de to bbc3e7a Compare August 24, 2026 16:30
@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 170.077662ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 95.288598ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 360.994625ms
Throughput 277.01 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 34.476600281s
Average Latency 344.109045ms
Throughput 145.03 requests/second

@pflynn-virtru pflynn-virtru changed the title fix(ci): scope SonarCloud analysis to production source fix(ci): SonarCloud analysis scope and Postgres analysis Aug 24, 2026
@pflynn-virtru
pflynn-virtru marked this pull request as ready for review August 24, 2026 16:37
@pflynn-virtru
pflynn-virtru requested review from a team as code owners August 24, 2026 16:37
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • service

See the workflow run for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:ci Github Actions Work size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants