Skip to content

BUILD-11394: Adds checking for manual setting of the SQ Project Key on check-sca#261

Merged
bwalsh434 merged 1 commit into
masterfrom
BUILD-11394-separate-config-file-for-sq-project-key-check-sca
May 19, 2026
Merged

BUILD-11394: Adds checking for manual setting of the SQ Project Key on check-sca#261
bwalsh434 merged 1 commit into
masterfrom
BUILD-11394-separate-config-file-for-sq-project-key-check-sca

Conversation

@bwalsh434
Copy link
Copy Markdown
Contributor

What Changed?

  • For the check-sca action, the action now checks the consumer repo's .github/check-sca.properties file for setting of the project-key
    • This allows repo owners with unconventional ways of setting their SQ project key to still make sure that the check-sca action can find their key

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 19, 2026

Agentic Analysis: Early Results

Agentic Analysis and Context Augmentation are available on your project. Here are some issues that could have been prevented. Follow the links to learn how to put them into action.

1 issue(s) found across 1 file(s):

Rule File Line Message
shelldre:S1192 spec/check-sca_spec.sh 251 Define a constant instead of using the literal 'explicit-key' 4 times.

Analyzed by SonarQube Agentic Analysis in 2.7 s

@bwalsh434 bwalsh434 marked this pull request as ready for review May 19, 2026 02:17
@bwalsh434 bwalsh434 requested a review from a team as a code owner May 19, 2026 02:17
Copilot AI review requested due to automatic review settings May 19, 2026 02:17
@sonar-review-alpha
Copy link
Copy Markdown
Contributor

sonar-review-alpha Bot commented May 19, 2026

Summary

This PR adds support for discovering SonarQube project keys via a new .github/repo-metadata.yaml file, enabling repos that use SonarCloud Automatic Analysis or other non-standard setups to explicitly configure their project key for the check-sca action.

What changed:

  • Added read_repo_metadata() helper to parse YAML metadata from the repo root
  • Integrated metadata file into the project key discovery pipeline with high priority (second only to explicit PROJECT_KEY_INPUT)
  • README updated with configuration instructions and example YAML structure
  • Comprehensive test coverage for various edge cases (quoted values, file extensions, priority ordering, subdirectory handling)

What reviewers should know

Start here: Review the two new helper functions (parse_property_value() and read_repo_metadata()) in check-sca/check-sca.sh to understand the parsing logic. The YAML parsing uses sed to extract values under the check-sca section.

Key design decisions to verify:

  • The metadata file is always read from the repo root ($GITHUB_WORKSPACE), not the working directory — this is correct for storing .github config files
  • .yaml is preferred over .yml (checked with break after first match)
  • Metadata discovery runs after explicit PROJECT_KEY_INPUT but before .sonarlint/connectedMode.json — a reasonable priority
  • The YAML parser strips quotes from values and handles whitespace

Test coverage is thorough: The spec file includes cases for both file extensions, quoted values, missing sections, priority ordering, and reading from repo root when working in subdirectories. Pay attention to the "prefers .yaml over .yml when both exist" test to confirm precedence logic.


  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod Bot commented May 19, 2026

BUILD-11394

sonar-review-alpha[bot]

This comment was marked as resolved.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support in the check-sca GitHub Action for discovering a SonarQube/SonarCloud project key from a manually maintained repo file (.github/check-sca.properties), intended to help repositories that don’t have standard scanner config files.

Changes:

  • Extend project-key discovery to read project-key=... from .github/check-sca.properties with high priority.
  • Add ShellSpec coverage for the new discovery source and update existing priority-order expectations.
  • Update README.md to document the new manual override file and discovery order.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
check-sca/check-sca.sh Adds .github/check-sca.properties as a new discovery source and adjusts priority numbering.
spec/check-sca_spec.sh Adds tests for reading/ignoring/prioritizing the new properties file; updates priority-order test.
README.md Documents the new discovery source and provides instructions for creating .github/check-sca.properties.
Comments suppressed due to low confidence (1)

check-sca/check-sca.sh:54

  • With set -euo pipefail, this grep | head | cut | tr pipeline returns a non-zero status when no project-key= line is present (or the file is malformed). That can cause discover_project_keys to exit early and skip all lower-priority sources, which contradicts the intended "ignore when malformed" behavior. Consider making the parse non-fatal (e.g., tolerate grep exit status) so missing/invalid lines don’t abort key discovery.
  if [[ -f "$checksca_props" ]]; then
    local key
    key=$(grep -E '^project-key=' "$checksca_props" 2>/dev/null | head -1 | cut -d= -f2- | tr -d '[:space:]')
    if [[ -n "$key" ]]; then
      keys+=("$key")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread check-sca/check-sca.sh Outdated
Comment thread README.md Outdated
Comment thread spec/check-sca_spec.sh
@bwalsh434 bwalsh434 force-pushed the BUILD-11394-separate-config-file-for-sq-project-key-check-sca branch from 79cc2e5 to 6cd16fd Compare May 19, 2026 02:30
@bwalsh434 bwalsh434 force-pushed the BUILD-11394-separate-config-file-for-sq-project-key-check-sca branch from 6cd16fd to 5733760 Compare May 19, 2026 02:39
sonar-review-alpha[bot]

This comment was marked as outdated.

@bwalsh434 bwalsh434 force-pushed the BUILD-11394-separate-config-file-for-sq-project-key-check-sca branch from 5733760 to 89ac21d Compare May 19, 2026 02:50
sonar-review-alpha[bot]

This comment was marked as outdated.

Comment thread check-sca/check-sca.sh
Copy link
Copy Markdown
Contributor

@jayadeep-km-sonarsource jayadeep-km-sonarsource left a comment

Choose a reason for hiding this comment

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

@bwalsh434 bwalsh434 force-pushed the BUILD-11394-separate-config-file-for-sq-project-key-check-sca branch from 89ac21d to c4e0347 Compare May 19, 2026 16:13
sonar-review-alpha[bot]

This comment was marked as resolved.

@bwalsh434 bwalsh434 force-pushed the BUILD-11394-separate-config-file-for-sq-project-key-check-sca branch from c4e0347 to beb03f6 Compare May 19, 2026 16:38
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@sonar-review-alpha sonar-review-alpha Bot left a comment

Choose a reason for hiding this comment

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

LGTM! ✅

🗣️ Give feedback

@bwalsh434 bwalsh434 merged commit 9d635dd into master May 19, 2026
16 checks passed
@bwalsh434 bwalsh434 deleted the BUILD-11394-separate-config-file-for-sq-project-key-check-sca branch May 19, 2026 16:43
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.

3 participants