GithubHelp home page GithubHelp logo

ericcornelissen / js-regex-security-scanner Goto Github PK

View Code? Open in Web Editor NEW
5.0 5.0 1.0 1.33 MB

A static analyzer to scan JavaScript code for problematic regular expressions.

Home Page: https://hub.docker.com/r/ericornelissen/js-re-scan

License: Apache License 2.0

Dockerfile 10.36% JavaScript 66.34% Makefile 23.29%
javascript redos regex regular-expression sast scanner security static-analysis

js-regex-security-scanner's People

Contributors

dependabot[bot] avatar ericcornelissen avatar step-security-bot avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

js-regex-security-scanner's Issues

Management of non-package registry dependencies

Some of this project's runtime and development dependencies are explicitly tracked (in package-lock.json or GitHub Actions workflows), some system-level development dependencies aren't explicitly tracked but this is considered fine1 (git, Make, Docker, Node.js & npm, EditorConfig), but some development dependencies aren't explicitly tracked and/or kept up-to-date but ideally are. This issue is about that last category.

Note: Feel free to comment on this issue if you think this list is incomplete or if you have any suggestions for improvements.

Overview

  • actionlint: ideally tracked & kept up-to-date.
  • Grype: ideally kept up-to-date.
    • Updated since #160
  • hadolint: ideally kept up-to-date.
  • ShellCheck: ideally tracked & kept up-to-date.
  • Syft: ideally kept up-to-date.
    • Updated since #160
  • yamllint: ideally tracked & kept up-to-date.

Footnotes

  1. If known, these should have a minimum required version specified to make contributing easier

Lint the Dockerfile

Relates to #38


Summary

Add a lint check for the Dockerfile to automatically enforce a common style and best-practices. As a start, use hadolint. Suggestion for alternatives/additions are welcome.

Lint the Dockerfile

Summary

Add a lint check for the Dockerfile to automatically enforce a common style and best-practices. As a start, use hadolint. Suggestion for alternatives/additions are welcome.

Add support for JSX

Relates to #4


Summary

Add support for properly scanning projects that use JSX.

At v0.2.6, running this scanner on a project with JSX source code (in .js files, or similar) will result in errors like:

X:Y  error  Parsing error: Unexpected token <

This change should include adding .jsx and .tsx extensions in the scope of the scanner.

Documentation tests

Summary

This is an idea to set up automation (preferably available locally and run in CI) that runs commands found in the documentation to ensure they succeed and are thus (by some definition) correct.

Support linting JavaScript snippets in MarkDown documentation

Summary

Add support for linting JavaScript snippets inside of MarkDown documentation in order to catch problematic regular expressions advertised in documentation. Regular expression appearing in documentation might be copied by readers and thus end up in code. As such, problematic regular expression in documentation should be reported on, to avoid such regular expression ending up in code (that isn't being scanned for problematic regular expression).

It should be possible to provide support for this using eslint-plugin-markdown.

Add license validation

Add continuous validation of the licenses of dependencies used by this project. This should make sure no dependency is introduces that's incompatible with this project's license.

This could potentially be built on the SBOM that is already being generated.

Prevent having to update snapshots for releases

Relates to #46


Summary

Per the Release Guidelines when creating a release it's necessary to update the test snapshots. This is because the scanner output always includes the current version number.

It's not really necessary to always output the version number, and having to update snapshots every release just for this reason is not ideal. Hence, ideally this is fixed by either:

  1. Updating the tests so that the snapshots don't need to be updated.
  2. Updating the scanner to not output the version number by default. (preferred)

Reproducible builds

Summary

The concept of a reproducible build aims to provide some guarantees on the relation between source and output artifact, namely that building from the same source twice always results in the same output artifact. For this project that roughly means that the container image resulting from make build is reproducible.

The goal of this issue is to

  1. Determine if the build is reproducible and under what constraints (e.g. target architecture)
    A. If it's not reproducible, fix that
  2. Implement a test in order to continuously verify the build is reproducible

Adopt new MarkDown alert extension in documentation

Summary

GitHub recently released a blog post announcing the adoption of a new MarkDown extension for displaying alerts (documentation). This issue exists to track the updating of the documentation to adopt this new extension.

To get an idea of the scope of this issue, most instances of existing "alerts" in the documentation can be found using this GitHub search query. (If you work on this locally, searching the entire codebase for the string > ** should give the same result.)

Ignore patterns

Relates to #12, #55

Summary

Add support for specifying (custom) file patterns that should be ignored by the scanner.

Example

When scanning ericcornelissen/svgo-action (with v0.3.1) the output will contain violations only for lib/index.cjs. While somewhat helpful, most of the code in that file is from external vendors and so is not directly relevant. In this case, it should be possible to scan the project's own source code separately from vendored code.

Lint JavaScript files

Relates to #38, #65, #70


Summary

Add a linter to automatically validate and enforce a style and (optionally) best-practices for JavaScript files. Initially this would probably be scoped to just the tests/. The contents of testdata/ should NOT be linted.

Avoid outputting errors/warnings due to references to unknown ESLint rules

When a project uses ESLint itself and has in-code eslint-ignore-* comments, running this project on it results in errors/warnings about unknown rules. For example:

[...]

/project/path/to/some/file.js
  2:1  error  Definition for rule '@typescript-eslint/no-explicit-any' was not found  @typescript-eslint/no-explicit-any

[...]

This is not ideal because it introduces noise and makes the exit code (ref #3) useless.

Remove temporary logic from `reusable-audit.yml`

Caused by #302, #306
Relates to #265

Summary

Resolve the following temporary logic from the reusable-audit.yml workflow configuration upon the release of v0.4.5/v0.5.0:

# The 7 lines following this comment block, as well as the block itself,
# should be removed when the `.nvmrc` file is available at the `v0` ref.
if: ${{ matrix.ref != 'v0' }}
- if: ${{ matrix.ref == 'v0' }}
name: Install Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
cache: npm
node-version: 20

Set up dependency scanning

Related to #2


Set up security scanning of dependencies (at least the Docker image and npm). Ideally these are scanned for all changes, as well as periodically for the HEAD of development as well as the latest released version.

Remove temporary logic from `reusable-audit.yml`

Relates to #263

Summary

Resolve the following temporary logic from the configuration after/upon the release of v0.4.3/v0.5.0:

# The 4 lines following this comment block, as well as the block itself,
# should be removed when the `make audit-image` target is available at
# the `v0` ref.
if: ${{ matrix.ref != 'v0' }}
- name: Audit dependencies in container image
if: ${{ matrix.ref == 'v0' }}
run: make audit-docker

Upgrade to the Node.js v20 runtime

Summary

Upgrade from Node.js v18 to new LTS major version Node.js v20, release 2023-04-18.

To achieve this the following should be changed:

  • Contributing Guidelines prerequisites
  • Dockerfile base image
  • package*.json files engines.node value
  • CI workflows node-version values

This change should also be recorded in the changelog.

Ignore tests

Relates to #12


Summary

In general regexes in tests with bad runtime performance aren't a big problem. So, to reduce noise, this scanner shouldn't report on bad regular expressions in tests.

Patterns to consider:

  • e2e/
  • test/
  • tests/
  • spec/
  • specs/
  • __mocks__/
  • __tests__/
  • __specs__/
  • .{spec,test}.{cjs,js,mjs,ts}

Set up known-vulnerability scanning for container images

Relates to #539, #591, #592

Summary

Create a default audit command to audit container images (i.e. Containerfile) so as to stay on secure base images.

Suggestions, tips, thoughts are welcome.

Goals

The solution:

  • (must) be runnable by anyone.
  • (must) allow for ignoring specific vulnerabilities manually.
  • (ideally) allows for ignoring vulnerabilities without fixes.

Add LABELs to the Docker image

Update the Dockerfile to use some LABELs. Some ideas (suggestions are welcome, even after this issue is closed):

  • name: The name of the scanner.
  • description: A description of the scanner.
  • version: The version of the image.
  • license: The license of the image.

Provide a guide to migrate from this scanner to adopting `eslint-plugin-regexp`

Summary

Given this scanner just runs ESLint with a specific configuration, and many Node.js based projects use ESLint anyway, it would make sense to guide users to adopt eslint-plugin-regexp within their project instead of using this scanner. Using the plugin directly would be easier as well as (probably) provide quicker and more frequent feedback on regular expressions in their project.

To clarify, I still believe this scanner has value as it has its own use cases, e.g.:

  • By project owners of contributors while there are still problematic regular expressions that need to be addressed and so errors by ESLint are not yet as useful.
  • By a third-party to scan a project without having to change the configuration of the project they're looking at.

Lint YAML files

Relates to #38, #65


Summary

Add a linter to automatically validate and enforce a style and (optionally) best-practices for YAML files. Suggestions for a linter are welcome.

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.