Skip to content

Semgrep - Improve pre scan checks and ease of extending rules - #230

Merged
Franck-Boost merged 9 commits into
mainfrom
semgrep/default
Jul 7, 2025
Merged

Semgrep - Improve pre scan checks and ease of extending rules#230
Franck-Boost merged 9 commits into
mainfrom
semgrep/default

Conversation

@Franck-Boost

@Franck-Boost Franck-Boost commented Jul 4, 2025

Copy link
Copy Markdown
Collaborator

Improve pre-scan checks:

Modified the pre-scan check to ensure that custom rules are well-defined:

  • Move the check from the module setup to pre scan step so the error details could be visible in boost interface
  • Added the following checks:
    • A file of a remote URL must be either a .yaml or .yml
    • Fetching the URL must returns a HTTP 200 OK code
    • Ensure that the local files or directories exists in the code repository.
    • Ensure that the .semgrep directoy includes at least one yaml file.

Ease of extending rules:

  • Boost Semgrep rules set can now be referenced by boost/sast/rules/semgrep@stable or boost/sast/rules/semgrep@canary instead of providing an URL.
  • Local rules support a top level wildcard.

Smoke tests:
Smoke tests definition was updated to add tests cases for both valid and invalid custom ruleset.
https://github.com/boost-sandbox/module-tests-semgrep/actions/runs/16124713060

@Franck-Boost
Franck-Boost requested a review from SUSTAPLE117 July 7, 2025 18:19
@SUSTAPLE117
SUSTAPLE117 requested a review from Copilot July 7, 2025 18:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

Enhance the pre-scan validation for Semgrep custom rules and update the module configuration to invoke the new checks and use a local rules directory.

  • Extended prescan_checks.sh to verify URL extensions, HTTP status codes, file existence, and ensure at least one YAML rule is present.
  • Updated module.yaml to copy and run the new pre-scan script, default to boost/sast/rules/semgrep@stable rules, and adjust the Semgrep scan command to use the local .semgrep folder.

Reviewed Changes

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

File Description
scanners/boostsecurityio/semgrep/prescan_checks.sh New script implementing detailed pre-scan rule validation (URL extension, fetch status, local file checks)
scanners/boostsecurityio/semgrep/module.yaml Integrates the pre-scan script into setup/steps, updates default SEMGREP_RULES, and adjusts scan command
Comments suppressed due to low confidence (1)

scanners/boostsecurityio/semgrep/module.yaml:15

  • The setup section previously used a nested list (- - name:). Verify the indentation matches the expected structure—this may need an extra dash (- -) to nest correctly under setup:.
  - name: Utility scripts

Comment thread scanners/boostsecurityio/semgrep/prescan_checks.sh Outdated
Comment thread scanners/boostsecurityio/semgrep/prescan_checks.sh
SUSTAPLE117
SUSTAPLE117 previously approved these changes Jul 7, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Franck-Boost <francois.lajeunesse-robert@boostsecurity.io>
@Franck-Boost
Franck-Boost requested a review from SUSTAPLE117 July 7, 2025 19:03
@Franck-Boost
Franck-Boost merged commit 7e2c290 into main Jul 7, 2025
4 checks passed
victor-nb added a commit that referenced this pull request Jul 18, 2025
lindycoder added a commit that referenced this pull request Jan 28, 2026
This change is to add support for having env vars passed down to the test runners.

For security reasons and to avoid env pollution, an allow list of prefix can be given to the test-action, if an env var does not match, it will be rejected at parse time and cause a failure of the check. In the case where we do not provide a list of allowed env prefixes, no environment variable will be accepted.

Documentation for Setting Up Scanner Tests has also been updated
@Franck-Boost
Franck-Boost deleted the semgrep/default branch February 27, 2026 13:53
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.

4 participants