Skip to content

fix: semgrep init#129

Merged
andrzej-janczak merged 1 commit intomainfrom
fix/semgrep-init
May 26, 2025
Merged

fix: semgrep init#129
andrzej-janczak merged 1 commit intomainfrom
fix/semgrep-init

Conversation

@andrzej-janczak
Copy link
Copy Markdown
Contributor

This pull request fixes the handling of Semgrep rules by embedding the rules.yaml file directly into the binary, simplifying file access and improving test reliability. The most important changes include introducing an embedded file system for rules.yaml, updating the configuration logic to use the embedded file, and refactoring the tests accordingly.

Embedding Semgrep rules:

  • Introduced a new embedded package to embed the rules.yaml file into the binary using Go's embed package. Added a GetSemgrepRules function to retrieve the embedded rules. (plugins/tools/semgrep/embedded/semgrep.go)

Configuration logic updates:

  • Updated FilterRulesFromFile and GetSemgrepConfig functions to use the embedded rules.yaml data instead of reading from the file system. Removed file path and executable path dependencies. (tools/semgrepConfigCreator.go) [1] [2]

Test refactoring:

  • Modified tests to use the embedded rules.yaml data directly, removing the need for temporary files and directory structures. Simplified test cases and ensured they validate the new embedded logic. (tools/semgrepConfigCreator_test.go) [1] [2]

@codacy-production
Copy link
Copy Markdown

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.22% 92.86%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (a84eb7c) 4607 1428 31.00%
Head commit (481a128) 4585 (-22) 1411 (-17) 30.77% (-0.22%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#129) 14 13 92.86%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@andrzej-janczak andrzej-janczak merged commit c7a56ea into main May 26, 2025
10 checks passed
@alerizzo alerizzo deleted the fix/semgrep-init branch June 3, 2025 09:45
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.

2 participants