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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Thruput.Semgrep.Rules" Version="0.0.13" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Thruput.Semgrep.Rules" Version="0.0.13" />
                    
Directory.Packages.props
<PackageReference Include="Thruput.Semgrep.Rules" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Thruput.Semgrep.Rules --version 0.0.13
                    
#r "nuget: Thruput.Semgrep.Rules, 0.0.13"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Thruput.Semgrep.Rules@0.0.13
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Thruput.Semgrep.Rules&version=0.0.13
                    
Install as a Cake Addin
#tool nuget:?package=Thruput.Semgrep.Rules&version=0.0.13
                    
Install as a Cake Tool

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:

  1. Severity Policy: All rules must have severity: ERROR to serve as hard blocking gates.
  2. 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 -e somewhere") 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>.sh and 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.*\Z paired with pattern-not-regex for "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.
  3. Quoting Special Syntax: In YAML, all pattern strings containing colons, curly braces {}, brackets [], or quotes must be quoted to prevent parser errors.
  4. Mandatory Test Verification: Before committing or finalizing changes, execute the test suite:
    pytest
    
    Both the Python and C# rule test suites (including schema checks, positive detections, and false-positive guards) must pass with a 100% success rate.

📦 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)

  1. Add Dependency:
    [project.optional-dependencies]
    dev = [
        "thruput-semgrep-rules @ git+https://github.com/thruput/semgrep.git#subdirectory=python"
    ]
    
  2. Run Linter:
    thruput-semgrep .
    # or
    semgrep-python .
    
  3. 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.

  1. Add NuGet Package:
    dotnet add package Thruput.Semgrep.Rules
    
  2. Run Linter via MSBuild Target:
    dotnet build -t:ThruputSemgrepLint
    
  3. Enable Automatic Scan on Every Build (Optional): Add to .csproj or Directory.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.

  1. Get the script and rules:
    git clone https://github.com/thruput-io/semgrep.git
    
  2. 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.

  1. Get the script and rules:
    git clone https://github.com/thruput-io/semgrep.git
    
  2. Run Linter:
    ./semgrep/javascript/bin/semgrep-javascript .
    
There are no supported framework assets in this package.

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.

Version Downloads Last Updated
0.0.13 107 11/5/2026
0.0.12 142 10/21/2026
0.0.11 117 10/20/2026
0.0.10 128 10/19/2026
0.0.9 151 10/9/2026