Thruput.Semgrep.Rules
0.0.13
dotnet add package Thruput.Semgrep.Rules --version 0.0.13
NuGet\Install-Package Thruput.Semgrep.Rules -Version 0.0.13
<PackageReference Include="Thruput.Semgrep.Rules" Version="0.0.13" />
<PackageVersion Include="Thruput.Semgrep.Rules" Version="0.0.13" />
<PackageReference Include="Thruput.Semgrep.Rules" />
paket add Thruput.Semgrep.Rules --version 0.0.13
#r "nuget: Thruput.Semgrep.Rules, 0.0.13"
#:package Thruput.Semgrep.Rules@0.0.13
#addin nuget:?package=Thruput.Semgrep.Rules&version=0.0.13
#tool nuget:?package=Thruput.Semgrep.Rules&version=0.0.13
Thruput Semgrep Rules
Curated Semgrep rulesets for Python, .NET (C#), Bash, and JavaScript codebases. All rules are configured with ERROR severity to enforce strict, blocking quality gates in CI/CD.
🔄 Development & Verification Workflow
⚠️ Mandatory Invariant
Every single modification must be verified before work is considered complete.
Never assume a rule pattern or change works without running the test suite. Breaking changes, syntax errors, or unverified patterns are not allowed.
Rule Modification Requirements:
- Severity Policy: All rules must have
severity: ERRORto serve as hard blocking gates. - Paired Test Fixtures: Every rule YAML file (
*.yaml) must have a corresponding test fixture (.py,.cs, or.sh) containing:- At least one positive trigger case marked with
# ruleid: <rule-id>or// ruleid: <rule-id>. - At least one negative false-positive guard marked with
# ok: <rule-id>or// ok: <rule-id>. - Whole-file-scope rules (e.g. "the file must start with a shebang", "the file must set
-esomewhere") check a single fact about the entire file, so a positive and a negative case cannot coexist in one fixture. For these, put the positive case in<rule-id>.shand the negative case alone in<rule-id>.ok.sh; the test suite uses the.ok.<ext>file for the negative check when it exists. Every rule of this shape MUST be regex-anchored to the whole file (e.g.\A(?!#!)for "must start with X",(?s)\A.*\Zpaired withpattern-not-regexfor "must contain X somewhere") — never gated behind an unrelated token that happens to appear in the fixture, which lets the rule pass tests while detecting nothing on real code.
- At least one positive trigger case marked with
- Quoting Special Syntax: In YAML, all pattern strings containing colons, curly braces
{}, brackets[], or quotes must be quoted to prevent parser errors. - Mandatory Test Verification:
Before committing or finalizing changes, execute the test suite:
Both the Python and C# rule test suites (including schema checks, positive detections, and false-positive guards) must pass with a 100% success rate.pytest
📦 Consuming the Packages
🌐 Direct URL (semgrep --config)
Bundled single-file rulesets are built by scripts/bundle_rules.py and published to GitHub Pages and GitHub Releases so any repository can scan directly via URL without cloning:
# Scan all supported languages (Python, C#, Bash, JavaScript)
semgrep --error --config "https://thruput.se/semgrep/all.yaml" .
# Or scan a specific language ruleset
semgrep --error --config "https://thruput.se/semgrep/python.yaml" .
semgrep --error --config "https://thruput.se/semgrep/csharp.yaml" .
semgrep --error --config "https://thruput.se/semgrep/bash.yaml" .
semgrep --error --config "https://thruput.se/semgrep/javascript.yaml" .
To build the bundled YAML files locally into dist/site/:
python scripts/bundle_rules.py dist/site
🐍 Python (thruput-semgrep-rules)
- Add Dependency:
[project.optional-dependencies] dev = [ "thruput-semgrep-rules @ git+https://github.com/thruput/semgrep.git#subdirectory=python" ] - Run Linter:
thruput-semgrep . # or semgrep-python . - Programmatic Access:
from semgrep_rules import get_rules_path rules_dir = get_rules_path()
⚡ .NET (Thruput.Semgrep.Rules)
The .NET package includes an auto-bootstrapping mechanism that automatically downloads the standalone Semgrep binary on first execution if not already installed.
- Add NuGet Package:
dotnet add package Thruput.Semgrep.Rules - Run Linter via MSBuild Target:
dotnet build -t:ThruputSemgrepLint - Enable Automatic Scan on Every Build (Optional):
Add to
.csprojorDirectory.Build.props:<PropertyGroup> <EnableThruputSemgrepOnBuild>true</EnableThruputSemgrepOnBuild> </PropertyGroup>
🐚 Bash (bash/bin/semgrep-bash)
A standalone shell script, not a Python package — Bash consumers do not need Python installed to lint Bash. It only needs the real semgrep binary on PATH.
- Get the script and rules:
git clone https://github.com/thruput-io/semgrep.git - Run Linter:
./semgrep/bash/bin/semgrep-bash .
🟨 JavaScript (javascript/bin/semgrep-javascript)
A standalone shell wrapper around Semgrep's JavaScript/TypeScript analyzer (languages: [javascript, typescript]) that scans .js and .mjs files with zero Node or Python wrapper dependencies.
- Get the script and rules:
git clone https://github.com/thruput-io/semgrep.git - Run Linter:
./semgrep/javascript/bin/semgrep-javascript .
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.