Coder Social home page Coder Social logo

baronsam3di / semgrep-rules Goto Github PK

View Code? Open in Web Editor NEW

This project forked from semgrep/semgrep-rules

0.0 0.0 0.0 4.65 MB

Semgrep rules registry

Home Page: https://semgrep.dev/registry

License: Other

Python 22.31% Java 25.06% Makefile 0.03% JavaScript 17.64% Go 8.36% C 0.55% Ruby 3.80% HTML 3.07% Pug 0.33% OCaml 0.23% Vue 0.01% HCL 8.18% TypeScript 2.40% PHP 1.36% Dockerfile 0.93% Mustache 0.71% EJS 0.49% Kotlin 1.00% Jinja 0.56% C# 2.99%

semgrep-rules's Introduction

semgrep-rules

powered by semgrep r2c community slack

branch using semgrep docker image test status
develop returntocorp/semgrep:develop semgrep-rules-test-develop

Welcome! This repository is the “standard library” for Semgrep rules, but there are many more written by r2c and other contributors available in the Semgrep Registry. If there a specific rule you are looking for, you can also search the Semgrep registry here.

How do I use these rules?

We recommend starting with semgrep --config auto. The --config auto flag will fetch rules relevant to your project from Semgrep Registry. The name of your project will be sent to Semgrep Registry as an identifier to make selecting relevant rules fast next time; source code will not be uploaded.

Alternatively, you can start with a pre-selected subset of rules that has already been carefully tuned for precision. These subsets of rules, which we call rulesets, may include rules not present in this repository. However, they are available for free on the Semgrep Registry. These rules have been written by open-source contributors and r2c.

The two most popular rulesets are:

  • semgrep --config=p/ci to find logic bugs and high-confidence security vulnerabilities; recommended for CI
  • semgrep --config=p/security-audit to find security audit points; noisy, recommended for manual scans

If you are determined to drink from the firehose, you can also pull directly from the registry by specifying r/<foldername.subfolder.etc>. So to run all the Python Flask rules from the python/flask directory in this repo, just run:
semgrep --config=r/python.flask

Semgrep releases new versions very frequently and the rules in this repo are always updated to take advantage of new features or fix breaking changes on new releases. For that reason, we suggest that you avoid stale copies of registry rules.

Contributing

We welcome Semgrep rule contributions directly to this repository! Since this repo is maintained by r2c, there are some extra benefits-for example, if there are bug reports for your rule, we’ll take responsibility to help fix it. If you are submitting to the semgrep-rules repo (rather than your own, separate repository as mentioned above) we’ll ask you to make r2c a joint owner of your contributions. While you still own copyright rights to your rule, joint ownership allows r2c to license these contributions to other Semgrep Registry users pursuant to the LGPL 2.1 under the Commons Clause. Check out the Contributing Guidelines to get started.

You can also contact us at [email protected] to make Semgrep rule contributions. We will import your rules for everyone to use!

Rulesets

Rulesets -- combined sets of rules from the Semgrep registry -- are organized in a private repository. If you want to modify existing sets or create your own, please contact us at [email protected].

If you have more questions, please see the FAQ section in the Semgrep docs.

Help

Join Slack for the fastest answers to your questions! Or contact the team at [email protected].

Rule Namespacing

The namespacing format for contributing rules is <language>.<framework>.<category>.$MORE. If a framework isn't applicable, use lang instead.

category is one of:

  • security
  • correctness
  • best-practice
  • maintainability
  • performance

If a security rule is discouraging the use of a bad pattern (such as formatted SQL strings), we recommended appending audit to your namespace. This distinguishes it from a security rule that is specifically aiming to detect a vulnerability.

semgrep.live rule namespace

Github Action To Run Tests

If you fork this repo or create your own, you can add a special semgrep-rules-test Github Action to your workflow that will automatically test your rules by running make test using the latest version of semgrep.

See ours here

Benchmarks

The benchmark job runs every weekend. It uploads a few artifacts, which can be downloaded. If you download the test logs, there are two relevant pieces of information in there: the benchmark table, which roughly shows the performance of every rule that completes in under 60 seconds, and any failed tests are rules that did not complete within 60 seconds.

To run benchmark tests locally, do the following from the root of semgrep-rules:

pipenv shell
pipenv install --dev
export PYTHONPATH=.
pytest --timeout=60 --rule-directory=[path_to_rule_directory] --git-repo=[git_URL] tests/performance/test_public_repos.py

If you omit --git-repo from the pytest command, it will run the provided benchmark repo.

semgrep-rules's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.