diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8322c12 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,19 @@ +# Only what the image needs: main.js, config files, core/, langs/, data/ and the npm manifests. +.git +.github +node_modules +bench +test +assets +scripts +*.md +!langs/**/*.md +!LICENSE.md +!THIRD_PARTY_NOTICES.md +report.* +asst-out +asst-results +.asst-cache +langs/**/docs/*.docx +Dockerfile +.dockerignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..477df22 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,106 @@ +name: CI + +on: + push: + branches: [main, v2] + pull_request: + schedule: + - cron: "17 3 * * *" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: test (${{ matrix.os }}, Node ${{ matrix.node }}) + if: github.event_name != 'schedule' + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + node: [18, 20, 22, 24] + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: ${{ matrix.node }} + cache: npm + - name: Install (same command as the README) + run: npm ci + - name: Unit, fixture and install-layout smoke tests + run: npm test + + benchmark: + name: benchmark (fixtures, DVWA, SARD 2k sample) + if: github.event_name != 'schedule' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 22 + cache: npm + - run: npm ci + - name: Cache benchmark downloads + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: bench/.work/downloads + key: bench-downloads-${{ hashFiles('bench/datasets.json') }} + - name: Precision/recall regression gate + run: npm run bench:ci + + action: + name: GitHub Action (composite, runs from this repository) + if: github.event_name != 'schedule' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - name: Scan the vulnerable PHP fixture with the action + id: asst + uses: ./ + with: + path: test/fixtures/php-vulnerable-app + language: php + fail-on: none + upload-sarif: 'false' + output: asst-results + - name: Check the action outputs + env: + SARIF: ${{ steps.asst.outputs.sarif }} + CODE: ${{ steps.asst.outputs.exit-code }} + run: | + test "$CODE" = "0" + test -s "$SARIF" + test -s asst-results/report.html + node -e "const s=JSON.parse(require('fs').readFileSync(process.env.SARIF,'utf8')); const n=s.runs[0].results.length; if (n < 10) throw new Error('only ' + n + ' results'); console.log(n + ' results');" + + nightly: + name: nightly (full SARD suite + WordPress throughput) + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + timeout-minutes: 300 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 22 + cache: npm + - run: npm ci + - name: Cache benchmark downloads + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: bench/.work/downloads + key: bench-downloads-${{ hashFiles('bench/datasets.json') }} + - name: Full benchmark + run: node bench/run.js --datasets fixtures,fixtures-app,dvwa,sard,wordpress --sard-sample 0 --versions head --json bench-results.json + - name: Upload results + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: benchmark-results + path: bench-results.json diff --git a/.gitignore b/.gitignore index 1cb3e76..494fac2 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,16 @@ node_modules # Generated by Windows Thumbs.db -report.html \ No newline at end of file +report.html +# Benchmark datasets and scratch output (downloaded, never committed) +bench/.work/ + +# ASST cache (--online lookups) +.asst-cache/ + +# Report files written next to main.js or in CI +report.json +report.sarif +report.md +asst-out/ +asst-results/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..683787c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,120 @@ +# Changelog + +All notable changes to OWASP ASST are documented in this file. + +## [2.0.0] - Unreleased + +ASST 2.0 is a major upgrade built on the foundation of the original thesis release. + +### Highlights + +- A data-flow engine follows user input through PHP and Node.js code, functions and files, and understands escaping and validation for each output context. +- Findings are mapped to the OWASP Top 10:2025 and CWE. Each one has a severity, a confidence level, a code snippet and an embedded remediation guide. +- Reports in HTML (interactive), JSON, SARIF and Markdown; CI exit codes, baselines, a GitHub Action and a Docker image. +- Laravel, WordPress and Symfony support, and a Node.js/Express scanner. +- Dependency, end-of-life and secrets checks, an optional OSV.dev lookup, read-only live checks of the running site, and a php.ini audit. +- Benchmark results: F1 on the NIST SARD PHP sample rises from 35.6% to 66.5%, and on DVWA from 84.6% to 96.3%, while scans run several times faster. + +### Added + +- Data-flow (taint) analysis for PHP. Every PHP file is parsed, and user input is followed from request sources to dangerous functions through variables, arrays, string building, `sprintf`, functions, methods and classes. Sanitizers and validation checks are understood per output context: SQL quoting, HTML text/attribute/script/URL, shell quoting, LDAP filters, XPath, file paths and URLs. Each finding shows the data-flow trace from source to sink. +- New detections: server-side request forgery, open redirect, path traversal, XPath injection, insecure deserialization, variable extraction (`extract`/`parse_str`), log and mail-header injection, code injection through `eval`/`assert`/`create_function`, unsafe dynamic calls, execution after redirect, weak password hashing, predictable random tokens, loose comparison of secrets, session fixation, hard-coded credentials, errors and `phpinfo()` shown to visitors, database error disclosure, DOM-based XSS and JavaScript `eval`, and version-control folders, backups, keys and dumps inside the web root. +- Remediation guides in Markdown (`langs/php/guides/`), one section per rule, written for current PHP 8 practice and the OWASP Top 10:2025. The relevant section is shown under each finding in the HTML report and used as rule help in SARIF. +- Cross-file analysis: `include`/`require` targets are resolved (including `__DIR__`, `define()`d paths and file names chosen in a `switch`) and run in the including scope, and functions and classes are resolved across the whole project. A vulnerability inside a shared helper lists the entry scripts that reach it. +- Framework packs for Laravel, WordPress and Symfony, detected automatically. Framework request objects, escaping helpers (`e()`, `esc_html()`, `esc_attr()`, `esc_url()`, `absint()`, `sanitize_*()`), query builders, `$wpdb` and HTTP clients are part of the data-flow analysis. New checks cover raw Blade (`{!! !!}`) and Twig (`|raw`, `autoescape false`) output, mass assignment (`$guarded = []` with `create($request->all())`), debug mode in `.env`, `config/app.php` and `wp-config.php`, CSRF exemptions in `VerifyCsrfToken`, `$wpdb` queries built without `prepare()`, and WordPress AJAX/admin-post handlers without nonce and capability checks. CSRF checks recognize `@csrf`, `csrf_field()`, `wp_nonce_field()` and Symfony `csrf_token()`. The report header lists the detected frameworks. +- Callback-aware data flow for `array_map()` with built-in callbacks such as `intval` or `htmlspecialchars`. +- Software supply chain checks. Every report gets a Components section listing: + - the dependencies from `composer.lock`, `package-lock.json` (v1–v3) and `yarn.lock`; + - JavaScript libraries copied into the project: jQuery, jQuery UI, Bootstrap, AngularJS, Lodash, Underscore, Moment.js, Handlebars, Vue, DOMPurify, TinyMCE and Knockout. + + Published advisories for these libraries ship with ASST. With `--online` (or `ONLINE_CHECKS: true`), every package is checked against OSV.dev. Only package names and versions are sent, and answers are cached for a day. +- End-of-life checks for frameworks and libraries: Laravel, Symfony, Drupal, WordPress, jQuery, Bootstrap, AngularJS and Vue. Also new: detection of development packages installed in a production `vendor/` folder, and of abandoned Composer packages. +- Secrets detection covers: + - API keys and tokens with well-known formats: AWS, GitHub, GitLab, Slack, Stripe, Google, SendGrid, npm, OpenAI and Anthropic; + - private keys and JSON Web Tokens; + - passwords in connection URLs; + - password, secret and key assignments in code, `.env` files and configuration files. + + Secrets are masked everywhere in the reports, including the code snippets of other findings. +- `npm run update-data` refreshes the bundled lifecycle and advisory data. `--online` also refreshes lifecycle dates from endoflife.date during a scan. +- Opt-in live checks of the running site with `--url http://localhost/YourProject/` (or `LIVE_SCAN_URL`). They report: + - missing security headers, version banners, and cookies without HttpOnly/Secure/SameSite; + - plain HTTP when HTTPS is available, and CORS origin reflection; + - PHP error output and directory listings; + - whether backups, dumps, `.env` files, `.git` data and manifests found by the static scan can actually be downloaded. Confirmed files are raised to critical. + + The checks are read-only: GET and HEAD requests only, at most 60 requests at five per second, no cookies or form submissions, and no response content copied into reports. Only localhost and private networks are contacted, unless `--allow-remote` is given for a site you are authorized to test. +- php.ini audit through the configured PHP binary. It covers: + - `display_errors`, `expose_php` and `allow_url_include`; + - session cookie and session id settings (`HttpOnly`, `SameSite`, `Secure`, `use_strict_mode`); + - optional hardening: `open_basedir`, `disable_functions`, `allow_url_fopen`, `zend.assertions`. +- When ASST runs from an XAMPP `htdocs` folder, the report suggests the matching `--url` for the live checks. +- Node.js plugin (`--lang nodejs`, or `USED_PROGRAMMING_LANGUAGE: "nodejs"`) for JavaScript and TypeScript applications built with Express and Express-style frameworks. It uses the same data-flow engine as the PHP scanner, follows request data (`req.query`, `req.body`, `req.params`, cookies, headers) through functions, callbacks, promises and modules, and reports: + - SQL injection (mysql/mysql2, pg, Knex, Sequelize, Prisma raw queries) and NoSQL injection (MongoDB/Mongoose operators and `$where`); + - command and argument injection, and code injection through `eval`/`Function`/`vm`/string timers and dynamic `require()`/`import()`; + - XSS in responses and in raw template output (EJS, Handlebars, Pug, Nunjucks, Vue); + - path traversal, SSRF, open redirects, regular expressions built from user input, prototype pollution through deep merges, and unsafe deserialization; + - configuration issues: missing helmet/security headers, CORS that trusts every origin, session cookie settings, JWT verification without a fixed algorithm, disabled TLS certificate checks, `express.static()` on the project folder, weak password hashing, `Math.random()` tokens, and end-of-life Node.js versions in `.nvmrc`, `engines` or Docker images. + + Dependencies, secrets and live checks work as for PHP, and the plugin comes with its own remediation guides. `--lang auto` picks the plugin from the project's files; PHP stays the default. +- Annotated Node.js fixture corpus and a sample Express application, used as ground truth in the automated tests. +- Findings are mapped to the OWASP Top 10:2025 (with the 2021 category) and to CWE, and carry a severity, a confidence level and a code snippet. +- Interactive HTML report: one self-contained file that works offline, with severity tiles, search, filters (severity, confidence, OWASP category), grouping by category/file/rule, code snippets with the line highlighted, data-flow traces, dark mode and print layout. Content is fully HTML-escaped and protected by a strict Content-Security-Policy. +- SARIF 2.1.0 output (`--format sarif`) for GitHub code scanning and IDE viewers, with CWE/OWASP tags, security-severity scores, stable fingerprints and data-flow code flows. +- Markdown summary (`--format md`) for pull-request comments and CI job summaries. +- JSON report (`--format json`) with a versioned schema. +- Baseline comparison: `--update-baseline` records the current findings, and `--baseline` marks later findings as new or unchanged and lists fixed ones in every report format. +- Up-to-date lifecycle data (`data/eol.json`) for PHP, MySQL, MariaDB, Node.js and the frameworks and libraries above; stored passwords are classified by hash format (bcrypt/argon2, fast hashes, plain text) and the database server version is checked against its support dates. +- New options: `--second-order` (treat session data, files, database rows and command output as untrusted), `--min-severity`, `--min-confidence`, `--fail-on` for CI, `--rules`/`--disable-rules`, `--baseline`/`--update-baseline`, and inline `asst-ignore[RULE-ID]` comments. +- Command-line options (`node main.js --help`): choose the folder to scan (`--path`), report location (`--out`), exclusions (`--exclude`), dependency folders (`--include-vendor`), PHP binary (`--php-bin`), skip database checks (`--no-db`), quiet and no-color modes. Running `node main.js` without options works exactly as before. +- `.asstignore` file and `EXCLUDE_PATHS` setting to skip paths; `YOUR_WEBAPP_DBMS_PORT` setting; `ASST_DB_PASSWORD` (and `ASST_DB_HOST`, `ASST_DB_USER`, `ASST_DB_NAME`, `ASST_DB_PORT`, `ASST_PHP_BIN`) environment variables so credentials do not have to be stored in a file. +- Benchmark harness (`npm run bench`) that measures precision, recall and F1 per CWE on labeled PHP datasets: the ASST fixture corpus, DVWA, and the NIST SARD PHP Vulnerability Test Suite (42,212 cases), plus throughput on WordPress core. +- Fixture corpus of vulnerable and safe PHP code samples covering 25 CWEs, used as ground truth for automated tests. +- Automated test suite (`npm test`) and continuous integration on Windows, Linux and macOS with Node.js 18, 20, 22 and 24, including a check that the documented XAMPP installation layout keeps working. +- GitHub Action (`uses: OWASP/ASST@v2.0.0`): scans the repository, uploads the SARIF report to code scanning, writes the Markdown summary to the job page and applies a `fail-on` threshold. +- Docker image (`Dockerfile`): scans a project mounted at `/src` and writes the reports to `/out`, running as an unprivileged user. +- `ASST_PATH`, `ASST_OUT`, `ASST_LANG`, `ASST_URL` and `ASST_NO_DB` environment variables for containers and CI, and an `asst` command when ASST is installed as a package. +- `CONTRIBUTING.md` (rule authoring, the data-flow engine, adding a language) and `SECURITY.md` (vulnerability reporting, and what ASST does on your machine). + +### Improved + +- SQL injection detection follows queries built over several lines and inside functions, and recognizes prepared statements, escaping inside quotes and numeric conversions. +- Cross-site scripting detection understands where each value is written in the page (text, quoted or unquoted attribute, event handler, script, URL). +- Command injection detection covers the backtick operator and recognizes `escapeshellarg()` per argument. +- Redirect checks recognize every way a script stops (`exit;`, `die;`, `return`, `throw`). +- CSRF checks focus on POST forms and recognize framework token helpers. +- XML checks focus on the parser options that enable external entities on current PHP versions. +- Benchmark results (see `bench/RESULTS.md`): + - NIST SARD PHP sample: F1 rises from 35.6% to 66.5%; + - DVWA: F1 rises from 84.6% to 96.3%, with 100% precision. +- DOM-based XSS checks focus on real browser sources (URL, referrer, window name, cross-window messages) and skip minified third-party bundles. +- Faster scans: the project tree is walked once, and every file is read and parsed once. Measured times (see `bench/RESULTS.md`): + - NIST SARD sample: 3 s instead of 57 s; + - DVWA: under 1 s instead of 6 s; + - WordPress core (about 1,500 PHP files): under 20 seconds. +- Dependency folders (`vendor/`, `node_modules/`, `bower_components/`) and version-control folders are skipped by default. +- Paths are resolved relative to the ASST folder: ASST can be started from any directory, the folder may keep the name `ASST-main`, and `DEFAULT_PROJECT_PATH_TO_SCAN` accepts absolute paths on every operating system. +- The report is a complete, HTML-escaped document, and its links to the remediation guides are standard `file://` URLs that open on Windows, Linux and macOS. +- Database checks use a single connection, escaped identifiers and aggregate queries, and only ever read the length and prefix of stored password hashes, never the hashes themselves. MySQL 8 authentication is supported. +- A missing PHP binary or an unreachable database now produces a short note in the summary and the rest of the scan continues. +- The eleven PDF/DOCX guides were revised for PHP 8 and the OWASP Top 10:2025, covering prepared statements with PDO settings, per-argument shell escaping, context-aware output encoding, `password_hash()`-based password storage, HTTPS and HSTS configuration, current XML parser defaults, SSRF allow-lists, modern MongoDB and logging examples, and links to the 2025 categories. + +### Changed + +- Requires Node.js 18 or newer. Older versions get a clear message pointing to the current LTS release and to ASST v1.0.0. +- Dependencies: `colors` and `sync-mysql` were replaced by `mysql2` and Node.js built-ins. + +### Compatibility + +- The installation steps stay the same: the ASST folder next to the project in `htdocs`, `npm install`, then `node main.js`, `ASST.bat` or `ASST.sh`. The only new requirement is Node.js 18 or newer. +- `config.js` and `config_php_lang.js` files from v1.0 work unchanged; all existing settings keep their meaning, and every new setting is optional. +- Running `node main.js` without options scans the configured folder with the PHP scanner, writes `report.html` next to `main.js` (still linking the PDF guides) and exits with code 0. Non-zero exit codes are used only with `--fail-on`, or when the scan cannot run. +- ASST v1.0.0, shown in the installation videos, stays available as the `v1.0.0` tag. + +## [1.0.0] - Original thesis release + +- Source-code security scanner for PHP/MySQL web projects, organized around the OWASP Top 10 categories. +- HTML report that points to the file and line of each finding and links to a remediation guide explaining the attack and how to prevent it. +- Eleven remediation guides (PDF/DOCX) covering injection, authentication, sensitive data exposure, XXE, security misconfiguration, XSS, vulnerable components, CSRF, SSRF and additional hardening. +- Server checks for PHP, XML parser and MySQL versions, and database checks for password storage. +- Installation guides and video walkthroughs for Windows, Ubuntu and macOS. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..2ce8710 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,118 @@ +# Contributing to OWASP ASST + +Thank you for helping developers write safer code! This guide explains how ASST is organized, how to add or improve rules, and how to add support for another language. + +## Getting started + +Requirements: Node.js 18 or newer, and Git. PHP and MySQL/MariaDB are only needed if you work on the runtime checks. + +```bash +git clone https://github.com/OWASP/ASST.git +cd ASST +npm ci +npm test # unit, fixture and install-layout tests +npm run bench # precision/recall on DVWA, NIST SARD and the fixtures (downloads the datasets once) +``` + +`npm run bench:ci` runs the regression gate used in CI: it fails when the F1 score of a dataset drops by more than two points against `bench/baseline-metrics.json`. If a change improves the results on purpose, update the baseline in the same pull request. + +## How ASST is organized + +``` +main.js Node.js version check, then core/runner.js +core/ language-independent engine + cli.js, config.js options: command line > ASST_* environment > config files > defaults + walker.js, file-cache.js + taint/ data-flow engine: value.js (abstract values), contexts.js (SQL, HTML, + shell, path, URL checks), interpreter.js (runs the IR), project.js + plugin-kit.js findings, data-flow messages, thresholds, baselines, report writing + supply/, secrets.js dependencies, lifecycles, OSV.dev, secrets + live/ opt-in read-only checks of a running site + report/ HTML, JSON, SARIF, Markdown, console + rules/common.js rules shared by every language (DEP-*, SECRET-*, LIVE-*) +langs// one folder per language plugin + index.js the plugin: detect() and scan() + taint/ parser, lowering to the IR, catalog of sources/sinks/sanitizers + rules/ registry (metadata) and structural/configuration rules + guides/*.md remediation guides, one section per rule +data/ lifecycle and advisory data (npm run update-data) +test/ unit tests, fixtures with @expect annotations, smoke tests +bench/ benchmark harness and results +``` + +## Adding or improving a rule + +1. **Metadata.** Add the rule to `langs//rules/registry.js` with: + - an id (`PHP-XYZ-001`, `NODE-XYZ-001`), a title and a CWE; + - the OWASP Top 10:2025 and 2021 categories; + - a default severity and a one-sentence summary; + - the guide anchor (`file#section`). +2. **Detection.** Choose the right place: + - *Data flow*: add sinks, sanitizers or guards to `langs//taint/catalog.js` (see below). + - *Structure or configuration*: add an AST rule (`ast-rules.js`, `config-rules.js`), or a text rule for templates. + - *Project level*: files, lock files, server configuration. +3. **Guide.** Add or extend a section `## Title {#anchor}` in `langs//guides/.md`: + - show the vulnerable pattern, the fix and references; + - keep the tone practical and positive. + + `npm test` checks that every rule points to an existing section. +4. **Fixtures.** Add vulnerable and safe samples under `test/fixtures//`: + - mark every expected finding on its line with a comment such as `// @expect CWE-89`; + - name safe variants `*.safe.*`; they must stay free of findings. +5. **Run** `npm test` and `npm run bench:ci`. + +Messages should say what happens and what to do, for example "User input reaches mysqli_query() inside a single-quoted string. Use prepared statements with bound parameters." Avoid jargon where a plain word works. + +## The data-flow engine in short + +Each language lowers its syntax tree into a small intermediate representation (IR), described at the top of `core/taint/interpreter.js`: +- statements: assignments, if, loops, switch, try, return; +- expressions: literals, variable paths, concatenation, calls, `new`, closures. + +The interpreter runs the IR with abstract values that remember: +- whether data is attacker-influenced, and with which confidence; +- which characters it can contain, and which encodings were applied; +- the trace from the source. + +The language **catalog** gives meaning to calls: + +```js +call(callee, args, expr, ctx) -> null | { + value, // the abstract result + sinks: [{ rule, arg, check }], // check: sql, html, shell, path, urlControl, code, ldap, xpath, crlf, any + byRef, // values written back to arguments + recvUpdate, // new value of the receiver (array.push) +} +guard(testExpr, evalExpr) // what a passing check (in_array, preg_match, validator.isInt) proves +entryArgs(fn) // parameter values for entry points nobody calls (request handlers) +``` + +Callee keys look like: +- `fn:mysqli_query` and `fn:child_process.exec` (functions); +- `m:query` (methods; the receiver value is in `ctx.recv`); +- `new:pg.pool` (constructors). + +Context checks in `core/taint/contexts.js` decide whether a value is safe where it is used. For example, a value escaped with `htmlspecialchars()` is safe in HTML text and quoted attributes, but not in a ` + + +`; +} + +module.exports = { render, extension: 'html', fileName: 'report.html', esc, SCRIPT, CATEGORY_NAMES }; diff --git a/core/report/index.js b/core/report/index.js new file mode 100644 index 0000000..d48f612 --- /dev/null +++ b/core/report/index.js @@ -0,0 +1,34 @@ +'use strict'; +/* + * Report output: writes every requested format and returns the written paths. + */ +const fs = require('fs'); +const path = require('path'); + +const FORMATS = { + html: () => require('./html'), + json: () => require('./json'), + sarif: () => require('./sarif'), + md: () => require('./markdown'), +}; + +/** + * @param {object} model report model (core/report/model.js) + * @param {object} config resolved configuration + * @returns {string[]} written file paths + */ +function writeReports(model, config) { + const written = []; + for (const format of config.formats) { + const factory = FORMATS[format]; + if (!factory) continue; + const renderer = factory(); + const file = format === 'html' ? config.htmlPath : path.join(config.outDir, renderer.fileName); + fs.mkdirSync(path.dirname(file), { recursive: true }); + fs.writeFileSync(file, renderer.render(model)); + written.push(file); + } + return written; +} + +module.exports = { writeReports, FORMATS }; diff --git a/core/report/json.js b/core/report/json.js new file mode 100644 index 0000000..b17d8ce --- /dev/null +++ b/core/report/json.js @@ -0,0 +1,13 @@ +'use strict'; +/* + * JSON report: the complete, versioned, machine-readable scan result. + */ + +function render(model) { + const { asstRoot, guides, ...rest } = model; + void asstRoot; + void guides; + return `${JSON.stringify(rest, null, 2)}\n`; +} + +module.exports = { render, extension: 'json', fileName: 'report.json' }; diff --git a/core/report/markdown.js b/core/report/markdown.js new file mode 100644 index 0000000..223e216 --- /dev/null +++ b/core/report/markdown.js @@ -0,0 +1,51 @@ +'use strict'; +/* + * Markdown summary, e.g. for pull-request comments or CI job summaries. + */ +const { SEVERITIES } = require('../finding'); + +const ICON = { critical: '🟣', high: '🔴', medium: '🟠', low: '🔵', info: '⚪' }; + +function cell(s) { + return String(s === undefined || s === null ? '' : s).replace(/\|/g, '\\|').replace(/\r?\n/g, ' '); +} + +function render(model, { maxDetailed = 25 } = {}) { + const s = model.summary; + const out = []; + out.push(`## OWASP ASST security report`, ''); + out.push(`Scanned **${model.scan.filesScanned}** files in ${(model.scan.durationMs / 1000).toFixed(1)} s with ASST ${model.tool.version}.`, ''); + out.push(`| ${SEVERITIES.map((sev) => `${ICON[sev]} ${sev}`).join(' | ')} | total |`); + out.push(`|${SEVERITIES.map(() => '---:').join('|')}|---:|`); + out.push(`| ${SEVERITIES.map((sev) => s.bySeverity[sev] || 0).join(' | ')} | **${s.total}** |`, ''); + if (s.fixed !== null && s.fixed !== undefined) { + out.push(`Compared with the baseline: **${model.findings.filter((f) => f.baseline === 'new').length} new**, ${s.fixed} fixed.`, ''); + } + if (model.findings.length) { + out.push('| Severity | Finding | Location | Rule |', '|---|---|---|---|'); + for (const f of model.findings.slice(0, maxDetailed)) { + const where = f.file ? `\`${cell(f.file)}${f.line ? `:${f.line}` : ''}\`` : (f.url ? cell(f.url) : 'project'); + out.push(`| ${ICON[f.severity]} ${f.severity} | ${cell(f.title)}${f.baseline === 'new' ? ' **(new)**' : ''} | ${where} | ${cell(f.ruleId)} (${cell(f.cwe)}) |`); + } + if (model.findings.length > maxDetailed) out.push('', `…and ${model.findings.length - maxDetailed} more in the full report.`); + out.push(''); + out.push('
Details', ''); + for (const f of model.findings.slice(0, maxDetailed)) { + out.push(`#### ${ICON[f.severity]} ${cell(f.title)} - ${f.file ? `\`${cell(f.file)}${f.line ? `:${f.line}` : ''}\`` : (f.url ? cell(f.url) : 'project')}`, ''); + out.push(f.message, ''); + if (f.trace && f.trace.length > 1) out.push(`Data flow: ${f.trace.map((t) => `line ${t.line} ${t.note}`).join(' → ')}`, ''); + } + out.push('
', ''); + } else { + out.push('No findings at the current reporting threshold. ✅', ''); + } + const inv = model.inventory && model.inventory.packages; + if (inv && inv.length) { + const vulnerable = inv.filter((c) => c.advisories).length; + out.push(`Components: ${inv.length} packages and bundled libraries, ${vulnerable} with published advisories (${model.inventory.advisorySource}).`, ''); + } + if (s.hidden) out.push(`_${s.hidden} lower-confidence or lower-severity findings are not listed._`, ''); + return `${out.join('\n')}\n`; +} + +module.exports = { render, extension: 'md', fileName: 'report.md' }; diff --git a/core/report/model.js b/core/report/model.js new file mode 100644 index 0000000..c843323 --- /dev/null +++ b/core/report/model.js @@ -0,0 +1,86 @@ +'use strict'; +/* + * Builds the report model shared by every output format (JSON, HTML, SARIF, Markdown). + */ +const path = require('path'); +const { SEVERITIES, CONFIDENCES } = require('../finding'); + +const SCHEMA = 'asst-report/1'; +const SNIPPET_CONTEXT = 3; + +/** Replaces every detected secret value with a masked placeholder. */ +function redactor(values) { + const list = [...(values || [])].filter((v) => typeof v === 'string' && v.length >= 3).sort((a, b) => b.length - a.length); + if (!list.length) return (l) => l; + return (line) => { + let out = line; + for (const v of list) if (out.includes(v)) out = out.split(v).join(`${'*'.repeat(8)}`); + return out; + }; +} + +function snippetFor(finding, project, cache, redact = (l) => l) { + if (!finding.file || !finding.line) return null; + const lines = cache.lines(path.join(project.root, finding.file)); + if (!lines) return null; + const start = Math.max(1, finding.line - SNIPPET_CONTEXT); + const end = Math.min(lines.length, finding.line + SNIPPET_CONTEXT); + return { startLine: start, lines: lines.slice(start - 1, end).map((l) => redact(l.length > 400 ? `${l.slice(0, 400)}…` : l)) }; +} + +function countBy(list, key, keys) { + const out = {}; + for (const k of keys || []) out[k] = 0; + for (const item of list) out[item[key] || 'none'] = (out[item[key] || 'none'] || 0) + 1; + return out; +} + +/** + * @param {object} p + * @returns {object} report model + */ +function buildModel(p) { + const redact = redactor(p.redact); + const findings = p.findings.map((f) => ({ ...f, snippet: f.snippet || snippetFor(f, p.project, p.cache, redact) })); + const finished = Date.now(); + return { + schema: SCHEMA, + tool: { name: 'OWASP ASST', version: p.config.version, homepage: 'https://github.com/OWASP/ASST' }, + scan: { + root: p.project.root, + language: p.language, + startedAt: new Date(p.startedAt).toISOString(), + finishedAt: new Date(finished).toISOString(), + durationMs: finished - p.startedAt, + filesScanned: p.stats.filesScanned, + filesAnalyzed: p.stats.filesAnalyzed, + parse: p.stats.parse, + skipped: p.project.skipped.map((s) => ({ path: s.rel, reason: s.reason })), + options: { + minSeverity: p.config.minSeverity, + minConfidence: p.config.minConfidence, + secondOrderSources: Boolean(p.config.secondOrder), + formats: p.config.formats, + }, + }, + summary: { + total: findings.length, + bySeverity: countBy(findings, 'severity', SEVERITIES), + byConfidence: countBy(findings, 'confidence', CONFIDENCES), + byCategory: countBy(findings, 'category'), + hidden: p.stats.hidden || 0, + suppressed: p.stats.suppressed || 0, + fixed: p.fixed ? p.fixed.length : null, + }, + environment: p.environment || {}, + inventory: p.inventory || null, + findings, + fixed: p.fixed || [], + notices: p.notices || [], + guides: p.guides || {}, + rules: p.rules || [], + asstRoot: p.config.asstRoot, + }; +} + +module.exports = { buildModel, SCHEMA }; diff --git a/core/report/sarif.js b/core/report/sarif.js new file mode 100644 index 0000000..160d980 --- /dev/null +++ b/core/report/sarif.js @@ -0,0 +1,105 @@ +'use strict'; +/* + * SARIF 2.1.0 output for GitHub code scanning, IDE viewers and other SARIF tools. + * Rules carry help text, CWE/OWASP tags and a numeric security-severity; results + * carry stable partial fingerprints and the data-flow trace as a code flow. + */ +const { pathToFileURL } = require('url'); + +const LEVEL = { critical: 'error', high: 'error', medium: 'warning', low: 'note', info: 'note' }; +const SECURITY_SEVERITY = { critical: '9.5', high: '8.0', medium: '5.5', low: '3.0', info: '1.0' }; +const PRECISION = { high: 'high', medium: 'medium', low: 'low' }; + +function ruleName(title) { + return String(title).replace(/\(.*?\)/g, '').split(/[^A-Za-z0-9]+/).filter(Boolean).map((w) => w[0].toUpperCase() + w.slice(1)).join(''); +} + +function location(file, line, column, snippet) { + const region = { startLine: line || 1 }; + if (column) region.startColumn = column; + if (snippet) region.snippet = { text: snippet }; + return { physicalLocation: { artifactLocation: { uri: encodeURI(file), uriBaseId: '%SRCROOT%' }, region } }; +} + +function render(model) { + const used = new Map(); + for (const f of model.findings) if (!used.has(f.ruleId)) used.set(f.ruleId, f); + const meta = new Map((model.rules || []).map((r) => [r.id, r])); + const ruleIds = [...used.keys()].sort(); + const rules = ruleIds.map((id) => { + const f = used.get(id); + const r = meta.get(id) || {}; + const guide = model.guides && f.guide ? model.guides[f.guide] : null; + const tags = ['security', f.cwe, f.category ? `OWASP ${f.category}` : null, f.owasp2021 ? `OWASP ${f.owasp2021}` : null].filter(Boolean); + const rule = { + id, + name: ruleName(f.title), + shortDescription: { text: f.title }, + fullDescription: { text: r.summary || f.title }, + help: { text: guide ? guide.text : (r.summary || f.title), markdown: guide ? guide.markdown : (r.summary || f.title) }, + defaultConfiguration: { level: LEVEL[r.severity || f.severity] || 'warning' }, + properties: { + tags, + precision: 'medium', + 'problem.severity': LEVEL[r.severity || f.severity] === 'note' ? 'recommendation' : LEVEL[r.severity || f.severity], + 'security-severity': SECURITY_SEVERITY[r.severity || f.severity] || '5.0', + }, + }; + if (f.cwe) rule.helpUri = `https://cwe.mitre.org/data/definitions/${String(f.cwe).replace(/\D/g, '')}.html`; + return rule; + }); + const index = new Map(ruleIds.map((id, i) => [id, i])); + + const results = model.findings.map((f) => { + const result = { + ruleId: f.ruleId, + ruleIndex: index.get(f.ruleId), + level: LEVEL[f.severity] || 'warning', + message: { text: f.message }, + partialFingerprints: { 'asst/v1': f.fingerprint || '' }, + properties: { severity: f.severity, confidence: f.confidence, precision: PRECISION[f.confidence] || 'medium', 'security-severity': SECURITY_SEVERITY[f.severity] }, + }; + if (f.file) { + const lineText = f.snippet && f.line ? f.snippet.lines[f.line - f.snippet.startLine] : undefined; + result.locations = [location(f.file, f.line, f.column, lineText)]; + if (f.trace && f.trace.length > 1) { + result.codeFlows = [{ + threadFlows: [{ + locations: f.trace.map((t) => ({ location: { ...location(f.file, t.line), message: { text: t.note || '' } } })), + }], + }]; + } + } else { + result.locations = []; + result.message.text = `[project] ${f.message}`; + } + if (f.url) result.properties.url = f.url; + if (f.baseline) result.baselineState = f.baseline === 'new' ? 'new' : 'unchanged'; + return result; + }); + + const root = pathToFileURL(model.scan.root).href.replace(/\/?$/, '/'); + const sarif = { + $schema: 'https://json.schemastore.org/sarif-2.1.0.json', + version: '2.1.0', + runs: [{ + tool: { + driver: { + name: 'OWASP ASST', + fullName: 'OWASP ASST - Automated Software Security Toolkit', + version: model.tool.version, + semanticVersion: /^\d+\.\d+\.\d+/.test(model.tool.version) ? model.tool.version : undefined, + informationUri: 'https://github.com/OWASP/ASST', + rules, + }, + }, + originalUriBaseIds: { '%SRCROOT%': { uri: root } }, + invocations: [{ executionSuccessful: true, startTimeUtc: model.scan.startedAt, endTimeUtc: model.scan.finishedAt }], + automationDetails: { id: `asst/${model.scan.language}/` }, + results, + }], + }; + return `${JSON.stringify(sarif, null, 2)}\n`; +} + +module.exports = { render, extension: 'sarif', fileName: 'report.sarif', LEVEL, SECURITY_SEVERITY }; diff --git a/core/rule-engine.js b/core/rule-engine.js new file mode 100644 index 0000000..4e0f5db --- /dev/null +++ b/core/rule-engine.js @@ -0,0 +1,102 @@ +'use strict'; +/* + * Declarative rule engine. Language plugins provide rule objects; the engine runs them + * over the project's files (each file read once through the shared FileCache) and + * turns their matches into findings. + * + * Rule kinds: + * { kind: 'line', extensions, pattern: RegExp, unless?: RegExp, when?(ctx), ... } + * one finding per matching line; `unless` suppresses a line, `when` may veto per match + * { kind: 'file', extensions, check(file, ctx) -> [{line?, column?, message?, ...overrides}] } + * { kind: 'project', check(ctx) -> [{file?, line?, message?, ...overrides}] } + * + * Shared metadata: id, title, category (OWASP 2025), owasp2021, cwe, severity, + * confidence, message, guide, pdf. + */ +const { createFinding, fingerprint } = require('./finding'); + +const META_KEYS = ['ruleId', 'title', 'category', 'owasp2021', 'cwe', 'severity', 'confidence', 'message', 'guide', 'pdf', 'trace', 'snippet']; + +function applies(rule, file) { + if (!rule.extensions || rule.extensions.length === 0) return true; + return rule.extensions.includes(file.ext) || (rule.filenames && rule.filenames.includes(file.name)); +} + +function build(rule, hit, ctx) { + const fields = { + ruleId: rule.id, + title: rule.title, + category: rule.category, + owasp2021: rule.owasp2021, + cwe: rule.cwe, + severity: rule.severity, + confidence: rule.confidence, + message: typeof rule.message === 'function' ? rule.message(hit) : rule.message, + guide: rule.guide, + pdf: rule.pdf, + }; + for (const k of META_KEYS) if (hit[k] !== undefined) fields[k] = hit[k]; + fields.file = hit.file !== undefined ? hit.file : null; + fields.line = hit.line || null; + fields.column = hit.column || null; + const lineText = fields.file && fields.line ? ctx.lineOf(fields.file, fields.line) : ''; + fields.fingerprint = fingerprint(fields.ruleId, fields.file || '', lineText, hit.fingerprintExtra || ''); + return createFinding(fields); +} + +/** + * @param {Array} rules + * @param {{files:Array, cache, lineOf(rel,n), textOf(rel), linesOf(rel)}} ctx + */ +function runRules(rules, ctx) { + const findings = []; + const errors = []; + const lineRules = rules.filter((r) => r.kind === 'line'); + const fileRules = rules.filter((r) => r.kind === 'file'); + const projectRules = rules.filter((r) => r.kind === 'project'); + + for (const file of ctx.files) { + const wantsLine = lineRules.filter((r) => applies(r, file)); + const wantsFile = fileRules.filter((r) => applies(r, file)); + if (wantsLine.length === 0 && wantsFile.length === 0) continue; + const lines = ctx.linesOf(file.rel); + if (!lines) continue; + for (const rule of wantsLine) { + try { + const scanLines = rule.useMaskedLines && ctx.maskedLinesOf ? ctx.maskedLinesOf(file.rel) : lines; + for (let i = 0; i < scanLines.length; i++) { + const text = scanLines[i]; + if (!text) continue; + rule.pattern.lastIndex = 0; + const m = rule.pattern.exec(text); + if (!m) continue; + if (rule.unless && rule.unless.test(text)) continue; + const hit = { file: file.rel, line: i + 1, column: m.index + 1, match: m, lineText: lines[i] }; + if (rule.when && !rule.when(hit, { ...ctx, file, lines })) continue; + findings.push(build(rule, hit, ctx)); + } + } catch (err) { + errors.push({ ruleId: rule.id, file: file.rel, error: err.message }); + } + } + for (const rule of wantsFile) { + try { + for (const hit of rule.check({ ...file, lines, text: ctx.textOf(file.rel) }, ctx) || []) { + findings.push(build(rule, { file: file.rel, ...hit }, ctx)); + } + } catch (err) { + errors.push({ ruleId: rule.id, file: file.rel, error: err.message }); + } + } + } + for (const rule of projectRules) { + try { + for (const hit of rule.check(ctx) || []) findings.push(build(rule, hit, ctx)); + } catch (err) { + errors.push({ ruleId: rule.id, error: err.message }); + } + } + return { findings, errors }; +} + +module.exports = { runRules }; diff --git a/core/rules/common.js b/core/rules/common.js new file mode 100644 index 0000000..0333fde --- /dev/null +++ b/core/rules/common.js @@ -0,0 +1,41 @@ +'use strict'; +/* + * Rules shared by every language plugin: dependencies (software supply chain) and + * secrets. Plugins add them to their registry with their own guide/PDF locations. + */ + +/** @param {(id,title,cwe,a2025,a2021,severity,guide,pdfKey,summary) => object} R the plugin's rule factory */ +function commonRules(R) { + return [ + R('DEP-001', 'Component with known vulnerabilities', 'CWE-1395', 'A03', 'A06', 'high', 'components#dependencies', 'components', + 'A third-party package or bundled library has published security advisories for the version in use. Upgrade to a fixed version.'), + R('DEP-002', 'Component is end of life', 'CWE-1104', 'A03', 'A06', 'medium', 'components#dependencies', 'components', + 'The component version no longer receives security fixes. Plan an upgrade to a supported release.'), + R('DEP-003', 'Development packages installed in production', 'CWE-1104', 'A02', 'A05', 'medium', 'components#dependencies', 'components', + 'Composer installed require-dev packages (test and debug tools) in this deployment. Deploy with composer install --no-dev.'), + R('DEP-004', 'Abandoned package', 'CWE-1104', 'A03', 'A06', 'low', 'components#dependencies', 'components', + 'The package is marked as abandoned by its maintainers and will not receive fixes. Move to the suggested replacement.'), + R('SECRET-001', 'Secret in source code', 'CWE-798', 'A07', 'A07', 'high', 'authentication#secrets', 'auth', + 'A password, API key, token or private key is stored in a project file. Move it to the environment or a secrets manager and rotate it.'), + + // opt-in live checks against the running site (--url) + R('LIVE-HDR-001', 'Security headers missing', 'CWE-693', 'A02', 'A05', 'low', 'misconfiguration#security-headers', 'hardening', + 'The site does not send browser security headers such as Content-Security-Policy, X-Content-Type-Options or frame protection.'), + R('LIVE-INFO-001', 'Server software versions disclosed', 'CWE-200', 'A02', 'A05', 'low', 'misconfiguration#information-disclosure', 'misconfig', + 'Response headers or error pages announce web server and PHP versions, which helps attackers pick matching exploits.'), + R('LIVE-COOKIE-001', 'Cookie without security attributes', 'CWE-1004', 'A02', 'A05', 'medium', 'authentication#session-cookies', 'auth', + 'A cookie is set without HttpOnly, Secure or SameSite, so scripts, plain-HTTP requests or other sites can use it.'), + R('LIVE-TLS-001', 'HTTP is not redirected to HTTPS', 'CWE-319', 'A04', 'A02', 'medium', 'cryptography#https', 'crypto', + 'The site answers over plain HTTP although HTTPS is available, so passwords and cookies can travel unencrypted.'), + R('LIVE-CORS-001', 'Cross-origin requests allowed from any site', 'CWE-942', 'A01', 'A01', 'medium', 'access-control#cors', 'hardening', + 'The server copies any Origin into Access-Control-Allow-Origin, so other websites can read its responses in a visitor\'s browser.'), + R('LIVE-LIST-001', 'Directory listing enabled', 'CWE-548', 'A02', 'A05', 'medium', 'misconfiguration#directory-listing', 'misconfig', + 'The web server lists the files of folders that have no index page.'), + R('LIVE-FILE-001', 'Sensitive file can be downloaded', 'CWE-538', 'A02', 'A05', 'high', 'misconfiguration#exposed-files', 'hardening', + 'A file that should not be public (backup, database dump, environment file, version-control data) is served by the web server.'), + R('LIVE-ERR-001', 'Error details shown in responses', 'CWE-209', 'A02', 'A05', 'medium', 'misconfiguration#error-handling', 'misconfig', + 'Pages show PHP warnings or stack traces with file paths and code details.'), + ]; +} + +module.exports = { commonRules }; diff --git a/core/runner.js b/core/runner.js new file mode 100644 index 0000000..4d26117 --- /dev/null +++ b/core/runner.js @@ -0,0 +1,111 @@ +'use strict'; +/* + * Scan orchestration: options -> configuration -> file discovery -> language plugin -> + * reports -> exit code. + */ +const fs = require('fs'); +const path = require('path'); +const ansi = require('./ansi'); +const { parseArgs, helpText, CliError } = require('./cli'); +const { loadConfig, ConfigError } = require('./config'); +const { walkProject, readIgnoreFile } = require('./walker'); +const { FileCache } = require('./file-cache'); +const plugins = require('./plugins'); + +function createNotices() { + const list = []; + return { + list, + add(kind, message) { + list.push({ kind, message }); + }, + }; +} + +function printNotices(notices, quiet) { + if (!notices.list.length || quiet) return; + console.log(''); + for (const n of notices.list) { + const color = n.kind === 'warning' ? 'yellow' : 'cyan'; + console.log(ansi.paint(`${n.kind === 'warning' ? 'Note' : 'Info'}: ${n.message}`, color)); + } +} + +/** @returns {Promise} process exit code */ +async function run(argv = process.argv.slice(2)) { + const started = Date.now(); + let cli; + try { + cli = parseArgs(argv); + } catch (err) { + if (err instanceof CliError) { + console.error(err.message); + return 2; + } + throw err; + } + if (cli.color === false) ansi.setEnabled(false); + + let config; + try { + config = loadConfig(cli); + } catch (err) { + if (err instanceof ConfigError) { + console.error(ansi.paint(err.message, 'red', 'bold')); + return 2; + } + throw err; + } + if (cli.help) { + console.log(helpText(config.version)); + return 0; + } + if (cli.version) { + console.log(config.version); + return 0; + } + + if (!config.quiet && process.stdout.isTTY) process.stdout.write('\u001bc'); // clear screen, as in v1 + + let stat = null; + try { stat = fs.statSync(config.scanPath); } catch (_) { /* handled below */ } + if (!stat || !stat.isDirectory()) { + console.error(ansi.paint(`The folder to scan was not found: ${config.scanPath}`, 'red', 'bold')); + console.error(`Set DEFAULT_PROJECT_PATH_TO_SCAN in ${path.join(config.asstRoot, 'config.js')} ` + + '(relative paths start from the ASST folder, e.g. "../YourProjectFolder/") or pass --path .'); + return 2; + } + + const ignoreGlobs = readIgnoreFile(path.join(config.scanPath, '.asstignore')); + const project = walkProject(config.scanPath, { + exclude: [...config.exclude, ...ignoreGlobs], + includeVendor: config.includeVendor, + skipPaths: [config.asstRoot], + }); + const cache = new FileCache({ maxBytes: config.maxFileSizeKB * 1024 }); + const notices = createNotices(); + const skippedDeps = project.skipped.filter((s) => s.reason === 'dependencies'); + if (skippedDeps.length) { + notices.add('info', `Skipped dependency folders (${skippedDeps.map((s) => s.rel).join(', ')}). Use --include-vendor to scan them.`); + } + + let plugin; + try { + plugin = plugins.select(config, project); + } catch (err) { + console.error(ansi.paint(err.message, 'red', 'bold')); + return 2; + } + + const result = await plugin.scan({ config, project, cache, notices }); + + printNotices(notices, config.quiet); + const seconds = Math.round((Date.now() - started) / 1000); + if (!config.quiet && !(result && result.model)) { + console.log(`Total scan time: ${seconds} Seconds`); + console.log(''); + } + return result && Number.isInteger(result.exitCode) ? result.exitCode : 0; +} + +module.exports = { run, createNotices }; diff --git a/core/secrets.js b/core/secrets.js new file mode 100644 index 0000000..32e2815 --- /dev/null +++ b/core/secrets.js @@ -0,0 +1,208 @@ +'use strict'; +/* + * Secret detection: provider tokens with well-known formats (high confidence), private + * keys, credentials in connection URLs, and password/secret/token assignments in code + * and configuration files (entropy and placeholder checks, medium confidence). + * + * The secret itself never reaches a report: messages show a masked form and every hit + * carries the raw value in `redact`, which the report builder masks in code snippets. + */ + +const PROVIDERS = [ + { label: 'AWS access key ID', hint: ['AKIA', 'ASIA', 'ABIA', 'ACCA'], re: /\b((?:AKIA|ASIA|ABIA|ACCA)[0-9A-Z]{16})\b/g }, + { label: 'AWS secret access key', hint: /secret_?access_?key/i, re: /aws_?secret_?access_?key['"]?\s*(?:=>|[:=])\s*['"]?([A-Za-z0-9/+]{40})(?![A-Za-z0-9/+])/gi }, + { label: 'GitHub token', hint: ['ghp_', 'gho_', 'ghu_', 'ghs_', 'ghr_'], re: /\b(gh[pousr]_[A-Za-z0-9]{36,251})\b/g }, + { label: 'GitHub fine-grained token', hint: ['github_pat_'], re: /\b(github_pat_[A-Za-z0-9_]{60,255})\b/g }, + { label: 'GitLab token', hint: ['glpat-'], re: /\b(glpat-[A-Za-z0-9_-]{20,})\b/g }, + { label: 'Slack token', hint: ['xox'], re: /\b(xox[abposr]-[A-Za-z0-9-]{10,})\b/g }, + { label: 'Slack webhook URL', hint: ['hooks.slack.com'], re: /(https:\/\/hooks\.slack\.com\/services\/T[A-Za-z0-9_]+\/B[A-Za-z0-9_]+\/[A-Za-z0-9_]{16,})/g, severity: 'medium' }, + { label: 'Stripe secret key', hint: ['_live_'], re: /\b((?:sk|rk)_live_[A-Za-z0-9]{20,})\b/g }, + { label: 'Google API key', hint: ['AIza'], re: /\b(AIza[0-9A-Za-z_-]{35})(?![0-9A-Za-z_-])/g, severity: 'medium', confidence: 'medium', note: 'Browser keys are public by design; make sure this key is restricted to your sites and APIs.' }, + { label: 'SendGrid API key', hint: ['SG.'], re: /\b(SG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43})(?![A-Za-z0-9_-])/g }, + { label: 'npm access token', hint: ['npm_'], re: /\b(npm_[A-Za-z0-9]{36})\b/g }, + { label: 'OpenAI API key', hint: ['T3BlbkFJ'], re: /\b(sk-(?:proj-|svcacct-|admin-)?[A-Za-z0-9_-]{16,}T3BlbkFJ[A-Za-z0-9_-]{16,})(?![A-Za-z0-9_-])/g }, + { label: 'Anthropic API key', hint: ['sk-ant-'], re: /\b(sk-ant-(?:api|admin)\d{2}-[A-Za-z0-9_-]{80,})(?![A-Za-z0-9_-])/g }, + { label: 'private key', hint: ['PRIVATE KEY'], re: /-----BEGIN ((?:RSA |EC |DSA |OPENSSH |PGP |ENCRYPTED )?PRIVATE KEY(?: BLOCK)?)-----/g, whole: true }, + { label: 'JSON Web Token', hint: ['eyJ'], re: /\b(eyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{16,})(?![A-Za-z0-9_-])/g, severity: 'medium', confidence: 'low' }, + { label: 'password in a connection URL', hint: ['://'], re: /\b(?:mysqli?|postgres(?:ql)?|mongodb(?:\+srv)?|redis|amqps?|s?ftp|smtps?):\/\/[^\s:@/'"]+:([^\s@/'"]{3,})@[^\s'"]+/g, confidence: 'medium' }, +]; + +const SECRET_NAME = /(?:passw(?:or)?d|passwd|\bpwd\b|_pwd\b|secret|api_?key|apikey|access_?token|auth_?token|client_?secret|private_?key|signing_?key|encryption_?key|app_key)/i; +const SECRET_NAME_G = new RegExp(SECRET_NAME.source, 'gi'); + +/** Cheap substring pre-check before running a provider pattern over a whole file. */ +function hinted(hint, text) { + if (!hint) return true; + if (hint instanceof RegExp) return hint.test(text); + return hint.some((h) => text.includes(h)); +} + +/** The header line plus every line of a private key block, so snippets never show key material. */ +function keyMaterial(text, m) { + const end = text.indexOf('-----END', m.index + m[0].length); + const body = end === -1 ? '' : text.slice(m.index + m[0].length, end); + return [m[0], ...body.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length >= 8)]; +} +const NOT_SECRET_NAME = /(?:_?(?:host|user(?:name)?|port|name|url|uri|path|file|id|type|length|min|max|field|label|placeholder|hint|reset|policy|confirm(?:ation)?|strength|regex|pattern|rules?|expires?|ttl|header|param|input)$)/i; + +const CODE_ASSIGN = /(['"]?)([A-Za-z_$][\w$.-]{0,60})\1\s*\]?\s*(?:=>|:|=)\s*(['"])([^'"\r\n]{6,200})\3/g; +const CONFIG_ASSIGN = /^\s*(?:export\s+)?([A-Za-z_][\w.-]{0,60})\s*[:=]\s*(['"]?)([^'"\s#;]{6,200})\2\s*(?:[#;].*)?$/; + +const PLACEHOLDER = /^(?:x+|\*+|\.+|-+|_+|0+|#+|null|nil|none|true|false|empty|undefined|changeme|change[_-]?me|password\d*|passwd|secret|example|sample|dummy|demo|test(?:ing)?|todo|fixme|redacted|placeholder|default|your[_-].*|my[_-]?(?:password|secret|key|token).*|enter[_-].*|insert[_-].*|put[_-].*|replace[_-].*|<[^>]*>|\$\{[^}]*\}|\$[A-Z_]+|%[^%]*%|\{\{[^}]*\}\}|\[[^\]]*\]|env\(.*|getenv\(.*)$/i; +const PLACEHOLDER_PART = /(?:EXAMPLE|xxxx|placeholder|dummy|change[_-]?me|your[_-]| re.test(s)).length; +} + +function looksLikeSecretValue(v) { + if (PLACEHOLDER.test(v) || PLACEHOLDER_PART.test(v)) return false; + if (/\s/.test(v) && v.split(/\s+/).length > 2) return false; // prose, labels + if (/^[_-]*[a-z]+(?:[_-][a-z0-9]+)*$/.test(v)) return false; // identifiers such as "user_password" + if (/^[A-Z]+(?:_[A-Z0-9]+)+$/.test(v)) return false; // constant names such as FTP_PRIKEY + if (/^[^@\s]+@[^@\s]+\.[a-z]{2,}$/i.test(v)) return false; // e-mail addresses + if (/^(?:https?:)?\/\//.test(v) || /^[./\\]/.test(v)) return false; // URLs and paths + if (/^\d+$/.test(v) && v.length < 10) return false; + if (/^(?:[A-Za-z_]\w*::|\$|\{|%|\\)/.test(v)) return false; // code, templates, escapes + if (/^[0-9a-f]{40,128}$/i.test(v) === false && charClasses(v) < 2) return false; + return entropy(v) >= (charClasses(v) >= 3 ? 2.4 : 2.8); +} + +function mask(value, keepPrefix = 0) { + const prefix = keepPrefix ? value.slice(0, keepPrefix) : ''; + return `${prefix}${'*'.repeat(Math.min(8, Math.max(4, value.length - prefix.length)))} (${value.length} characters)`; +} + +function knownPrefix(value) { + const m = /^(AKIA|ASIA|ABIA|ACCA|gh[pousr]_|github_pat_|glpat-|xox[abposr]-|sk_live_|rk_live_|AIza|SG\.|npm_|sk-ant-|sk-proj-|sk-|eyJ)/.exec(value); + return m ? m[1].length : 0; +} + +function lineAt(starts, index) { + let lo = 0; + let hi = starts.length - 1; + while (lo < hi) { + const mid = (lo + hi + 1) >> 1; + if (starts[mid] <= index) lo = mid; + else hi = mid - 1; + } + return lo + 1; +} + +/** + * @param {{rel:string, name:string, ext:string}} file + * @param {string} text + * @returns {Array<{ruleId, line, column, severity?, confidence, message, redact}>} + */ +function kindOf(file) { + if (SKIP_NAME.test(file.name)) return null; + const isEnv = /^\.env(?:\.|$)/.test(file.name) && !/\.(?:example|sample|dist|template|defaults?)$/i.test(file.name); + if (isEnv || CONFIG_EXT.has(file.ext)) return 'config'; + if (CODE_EXT.has(file.ext)) return 'code'; + return null; +} + +/** True when scanSecrets() looks at this file (lets callers skip reading other files). */ +function wants(file) { + return kindOf(file) !== null; +} + +function scanSecrets(file, text) { + const kind = kindOf(file); + if (!kind) return []; + const isConfig = kind === 'config'; + const isCode = kind === 'code'; + if (!text || text.length > 2 * 1024 * 1024) return []; + if (file.ext === 'js' && /\n/.test(text) === false && text.length > 5000) return []; // minified bundle + + const starts = [0]; + for (let i = 0; i < text.length; i++) if (text.charCodeAt(i) === 10) starts.push(i + 1); + const testLike = TEST_PATH.test(file.rel); + const hits = []; + const seen = new Set(); + const add = (index, value, fields) => { + const line = lineAt(starts, index); + const key = `${line}|${value}`; + if (seen.has(key)) return; + seen.add(key); + hits.push({ + ruleId: 'SECRET-001', + line, + column: index - starts[line - 1] + 1, + ...fields, + confidence: testLike ? 'low' : (fields.confidence || 'high'), + redact: value, + }); + }; + + for (const p of PROVIDERS) { + if (!hinted(p.hint, text)) continue; + p.re.lastIndex = 0; + let m; + while ((m = p.re.exec(text)) !== null) { + const value = m[1]; + if (PLACEHOLDER.test(value) || PLACEHOLDER_PART.test(value) || /(.)\1{9,}/.test(value)) continue; + const shown = p.whole ? value : mask(value, knownPrefix(value)); + add(m.index, p.whole ? keyMaterial(text, m) : value, { + severity: p.severity, + confidence: p.confidence, + message: `A ${p.label} is stored in the source${p.whole ? '' : ` (${shown})`}. Remove it from the code, rotate it, and load it from the environment or a secrets manager.${p.note ? ` ${p.note}` : ''}`, + }); + } + } + + const reportAssignment = (index, name, value) => { + if (!SECRET_NAME.test(name) || NOT_SECRET_NAME.test(name)) return; + if (!looksLikeSecretValue(value)) return; + add(index, value, { + confidence: 'medium', + message: `"${name}" is set to a literal value (${mask(value)}). Keep passwords, keys and tokens out of source files; load them from environment variables or a secrets manager, and rotate this one.`, + }); + }; + + if (isConfig) { + const lines = text.split('\n'); + lines.forEach((l, i) => { + const m = CONFIG_ASSIGN.exec(l.replace(/\r$/, '')); + if (m) reportAssignment(starts[i] + l.indexOf(m[3]), m[1], m[3]); + }); + } + if (isCode) { + // only lines that mention a secret-like name (plus the next line, for wrapped assignments) + SECRET_NAME_G.lastIndex = 0; + let k; + while ((k = SECRET_NAME_G.exec(text)) !== null) { + const line = lineAt(starts, k.index); + const begin = starts[line - 1]; + const lineEnd = line < starts.length ? starts[line] : text.length; + const end = line + 1 < starts.length ? starts[line + 1] : text.length; + const chunk = text.slice(begin, end); + CODE_ASSIGN.lastIndex = 0; + let m; + while ((m = CODE_ASSIGN.exec(chunk)) !== null) { + if (m.index >= lineEnd - begin) break; + reportAssignment(begin + m.index + m[0].lastIndexOf(m[4]), m[2], m[4]); + } + SECRET_NAME_G.lastIndex = Math.max(SECRET_NAME_G.lastIndex, lineEnd); + } + } + return hits.sort((a, b) => a.line - b.line || a.column - b.column); +} + +module.exports = { scanSecrets, wants, mask, entropy, looksLikeSecretValue }; diff --git a/core/shell.js b/core/shell.js new file mode 100644 index 0000000..58056f7 --- /dev/null +++ b/core/shell.js @@ -0,0 +1,37 @@ +'use strict'; +/* + * Safe process execution helpers. Commands are always run with execFile (argument + * arrays, no shell), a timeout, and errors are returned instead of thrown. + */ +const { execFileSync } = require('child_process'); + +/** + * @returns {{ok:boolean, stdout:string, error:string|null}} + */ +function runFile(bin, args = [], { timeout = 20000, cwd } = {}) { + if (!bin) return { ok: false, stdout: '', error: 'no executable configured' }; + try { + const stdout = execFileSync(bin, args, { + encoding: 'utf8', + timeout, + cwd, + windowsHide: true, + stdio: ['ignore', 'pipe', 'pipe'], + maxBuffer: 16 * 1024 * 1024, + }); + return { ok: true, stdout: String(stdout).trim(), error: null }; + } catch (err) { + let error; + if (err.code === 'ENOENT') error = `executable not found: ${bin}`; + else if (err.code === 'ETIMEDOUT' || err.signal === 'SIGTERM') error = `timed out after ${timeout} ms`; + else error = String(err.stderr || err.message || err).split(/\r?\n/).filter(Boolean)[0] || 'command failed'; + return { ok: false, stdout: err.stdout ? String(err.stdout).trim() : '', error }; + } +} + +/** Runs a PHP snippet with the configured PHP CLI binary: php -r "". */ +function runPhp(bin, code, options) { + return runFile(bin, ['-r', code], options); +} + +module.exports = { runFile, runPhp }; diff --git a/core/supply/eol.js b/core/supply/eol.js new file mode 100644 index 0000000..f32f383 --- /dev/null +++ b/core/supply/eol.js @@ -0,0 +1,65 @@ +'use strict'; +/* + * Lifecycle data (end of life / end of active support) from https://endoflife.date. + * data/eol.json ships with ASST; --online refreshes it into the ASST cache folder. + */ +const fs = require('fs'); +const path = require('path'); +const http = require('../http'); + +const API = 'https://endoflife.date/api'; +const PRODUCTS = ['php', 'mysql', 'mariadb', 'nodejs', 'laravel', 'symfony', 'drupal', 'wordpress', 'jquery', 'bootstrap', 'angularjs', 'vue']; +const TTL_MS = 24 * 60 * 60 * 1000; + +/** Keeps the fields lifecycle() reads. eol/support are an ISO date, true/false or null. */ +function normalizeCycle(c) { + const val = (x) => (x === undefined ? null : x); + return { cycle: String(c.cycle), eol: val(c.eol), support: val(c.support), lts: val(c.lts) || false, latest: c.latest ? String(c.latest) : null }; +} + +async function fetchAll({ products = PRODUCTS, client = http, today = new Date() } = {}) { + const out = { + source: `https://endoflife.date (${products.join(', ')})`, + asOf: today.toISOString().slice(0, 10), + note: 'Refreshed with --online; security support ends at "eol", bug-fix support at "support".', + products: {}, + }; + const lists = await http.mapLimit(products, 4, (p) => client.getJson(`${API}/${p}.json`, { timeoutMs: 20000 })); + products.forEach((p, i) => { + if (!Array.isArray(lists[i])) throw new Error(`unexpected answer for ${p}`); + out.products[p] = lists[i].map(normalizeCycle); + }); + return out; +} + +/** + * Returns lifecycle data refreshed at most once a day (cached in cacheFile). + * @returns {Promise} data, or null when the cache is fresh enough to use as is + */ +async function refresh({ cacheFile, client, now = Date.now(), products } = {}) { + try { + const stat = fs.statSync(cacheFile); + if (now - stat.mtimeMs < TTL_MS) return JSON.parse(fs.readFileSync(cacheFile, 'utf8')); + } catch { + // no cache yet + } + const data = await fetchAll({ products, client, today: new Date(now) }); + try { + fs.mkdirSync(path.dirname(cacheFile), { recursive: true }); + fs.writeFileSync(cacheFile, JSON.stringify(data, null, 2)); + } catch { + // read-only ASST folder: use the fresh data for this run only + } + return data; +} + +/** Cached data from an earlier --online run, used when it is newer than the bundled file. */ +function cached(cacheFile) { + try { + return JSON.parse(fs.readFileSync(cacheFile, 'utf8')); + } catch { + return null; + } +} + +module.exports = { fetchAll, refresh, cached, normalizeCycle, PRODUCTS }; diff --git a/core/supply/index.js b/core/supply/index.js new file mode 100644 index 0000000..c96ef82 --- /dev/null +++ b/core/supply/index.js @@ -0,0 +1,197 @@ +'use strict'; +/* + * Software supply chain checks shared by the language plugins: + * inventory lock files (composer.lock, package-lock.json, yarn.lock) and bundled JS libraries + * advisories bundled advisory data for common front-end libraries (data/js-libs.json), and + * OSV.dev for every package with --online (names and versions only, cached 24 h) + * lifecycles end-of-life frameworks and libraries (data/eol.json, refreshed with --online) + * hygiene require-dev packages installed in production, abandoned Composer packages + */ +const fs = require('fs'); +const path = require('path'); +const { readLockFiles } = require('./lockfiles'); +const { detectBundled } = require('./jslibs'); +const osv = require('./osv'); +const eol = require('./eol'); +const { compare } = require('./semver'); +const { lifecycle, useData } = require('../lifecycle'); + +const OFFLINE_FILE = path.join(__dirname, '..', '..', 'data', 'js-libs.json'); +const SEVERITY_ORDER = ['low', 'medium', 'high', 'critical']; + +/** Packages whose version is the version of a framework or library tracked by endoflife.date. */ +const EOL_PRODUCTS = { + Packagist: { 'laravel/framework': 'laravel', 'symfony/http-kernel': 'symfony', 'drupal/core': 'drupal' }, + npm: { jquery: 'jquery', bootstrap: 'bootstrap', angular: 'angularjs', vue: 'vue' }, +}; + +let offlineCache = null; +function offlineAdvisories(file = OFFLINE_FILE) { + if (file !== OFFLINE_FILE) return JSON.parse(fs.readFileSync(file, 'utf8')); + if (!offlineCache) { + try { + offlineCache = JSON.parse(fs.readFileSync(OFFLINE_FILE, 'utf8')); + } catch { + offlineCache = { packages: {} }; + } + } + return offlineCache; +} + +function maxSeverity(list, fallback) { + let best = -1; + for (const a of list) best = Math.max(best, SEVERITY_ORDER.indexOf(a.severity)); + return best >= 0 ? SEVERITY_ORDER[best] : fallback; +} + +function advisoryName(a) { + return a.aliases && a.aliases.length ? a.aliases[0] : a.id; +} + +function displayName(p) { + return p.label ? `${p.label} ${p.version}` : `${p.name} ${p.version}`; +} + +function vulnerabilityHit(p, advisories) { + const fixes = advisories.map((a) => osv.fixedFor(a, p.version)); + const unfixed = fixes.filter((f) => !f).length; + const target = fixes.filter(Boolean).sort(compare).pop(); + const names = advisories.map(advisoryName); + const listed = names.slice(0, 4).join(', ') + (names.length > 4 ? ` and ${names.length - 4} more` : ''); + let message = `${displayName(p)}${p.bundled ? ' (bundled copy)' : ''} is affected by ${advisories.length} published ${advisories.length === 1 ? 'advisory' : 'advisories'}: ${listed}.`; + if (target) message += ` Upgrade to ${target} or later${unfixed ? `; ${unfixed} ${unfixed === 1 ? 'advisory has' : 'advisories have'} no fixed release yet` : ''}.`; + else message += ' No fixed release is listed; consider replacing the component.'; + if (p.dev) message += ' (development dependency)'; + const first = advisories.find((a) => a.summary); + if (first && advisories.length === 1) message += ` ${first.summary.replace(/\.?$/, '.')}`; + return { + ruleId: 'DEP-001', + file: p.file, + line: p.line, + severity: maxSeverity(advisories, 'high'), + confidence: p.dev ? 'low' : 'high', + message, + component: { ecosystem: p.ecosystem, name: p.name, version: p.version, advisories: advisories.map((a) => ({ id: a.id, aliases: a.aliases, severity: a.severity, summary: a.summary })), fixedIn: target || null }, + }; +} + +/** + * @param {{project, readText:(f)=>string|null, config:{online:boolean, asstRoot:string}, notices, today?:Date, + * extraComponents?:Array, client?:object}} p + * @returns {Promise<{hits:Array, inventory:object}>} + */ +async function scanSupplyChain(p) { + const today = p.today || new Date(); + const cacheDir = path.join(p.config.asstRoot || process.cwd(), '.asst-cache'); + const lock = readLockFiles(p.project, p.readText); + const bundled = detectBundled(p.project, p.readText); + const packages = [...lock.packages, ...bundled, ...(p.extraComponents || [])]; + const hits = []; + + for (const e of lock.errors) p.notices.add('info', `Lock file not read: ${e}`); + + // lifecycle data: bundled file, or fresher data from an earlier/current --online run + const cachedEol = eol.cached(path.join(cacheDir, 'eol.json')); + if (cachedEol) useData(cachedEol); + + let online = null; + let onlineError = null; + if (p.config.online) { + try { + useData(await eol.refresh({ cacheFile: path.join(cacheDir, 'eol.json'), client: p.client })); + } catch (err) { + p.notices.add('warning', `Lifecycle data could not be refreshed from endoflife.date (${err.message}); the bundled data was used.`); + } + if (packages.some((x) => x.ecosystem === 'npm' || x.ecosystem === 'Packagist')) { + try { + online = await osv.lookup(packages, { cacheFile: path.join(cacheDir, 'osv.json'), client: p.client }); + } catch (err) { + onlineError = err.message; + p.notices.add('warning', `OSV.dev could not be reached (${err.message}); dependency advisories come from the bundled data only.`); + } + } + } + + const offline = offlineAdvisories(); + const seen = new Set(); + const inventory = []; + for (const pkg of packages) { + const key = `${pkg.ecosystem}|${pkg.name}|${pkg.version}|${pkg.file}`; + if (seen.has(key)) continue; + seen.add(key); + + let advisories = null; + if (online && online.has(osv.keyOf(pkg))) advisories = online.get(osv.keyOf(pkg)); + else if (pkg.ecosystem === 'npm' && offline.packages && offline.packages[pkg.name]) { + advisories = offline.packages[pkg.name].filter((a) => osv.affects(a, pkg.version)); + } + if (advisories && advisories.length) hits.push(vulnerabilityHit(pkg, advisories)); + + const product = pkg.eolProduct || (EOL_PRODUCTS[pkg.ecosystem] || {})[pkg.name]; + let status = null; + if (product) { + const lc = lifecycle(product, pkg.version, today); + status = lc.status; + if (lc.status === 'eol') { + hits.push({ + ruleId: 'DEP-002', + file: pkg.file, + line: pkg.line, + confidence: pkg.dev ? 'low' : 'high', + message: `${displayName(pkg)} is end of life${typeof lc.eol === 'string' ? ` since ${lc.eol}` : ''} (release line ${lc.cycle}) and no longer receives security fixes. Upgrade to a supported release.`, + }); + } + } + + if (pkg.abandoned) { + hits.push({ + ruleId: 'DEP-004', + file: pkg.file, + line: pkg.line, + confidence: pkg.dev ? 'low' : 'high', + message: `${pkg.name} is marked as abandoned${typeof pkg.abandoned === 'string' ? `; the maintainers suggest ${pkg.abandoned}` : ''}.`, + }); + } + + inventory.push({ + ecosystem: pkg.ecosystem, + name: pkg.name, + version: pkg.version, + dev: Boolean(pkg.dev), + bundled: Boolean(pkg.bundled), + file: pkg.file, + advisories: advisories ? advisories.length : null, + lifecycle: status, + }); + } + + for (const d of lock.devInstalls) { + const names = d.names.slice(0, 5).join(', ') + (d.names.length > 5 ? ` and ${d.names.length - 5} more` : ''); + hits.push({ + ruleId: 'DEP-003', + file: d.lock, + line: null, + message: `${d.file} shows that development packages are installed (${names}). Test and debugging tools in a public deployment can expose code execution or information; deploy with composer install --no-dev.`, + }); + } + + const checkable = inventory.filter((x) => x.ecosystem === 'npm' || x.ecosystem === 'Packagist').length; + if (checkable && !online && !onlineError) { + const fromLocks = inventory.filter((x) => !x.bundled && (x.ecosystem === 'npm' || x.ecosystem === 'Packagist')).length; + if (fromLocks) { + p.notices.add('info', `${fromLocks} dependencies from lock files were listed but not checked against vulnerability databases. Run with --online to look them up on OSV.dev (only package names and versions are sent).`); + } + } + + return { + hits, + inventory: { + packages: inventory, + lockFiles: lock.lockFiles, + advisorySource: online ? 'OSV.dev (online)' : 'bundled data', + checkedOnline: Boolean(online), + }, + }; +} + +module.exports = { scanSupplyChain, offlineAdvisories, EOL_PRODUCTS }; diff --git a/core/supply/jslibs.js b/core/supply/jslibs.js new file mode 100644 index 0000000..b0bd6fb --- /dev/null +++ b/core/supply/jslibs.js @@ -0,0 +1,79 @@ +'use strict'; +/* + * Recognizes JavaScript libraries copied into a project (jquery-1.12.4.min.js, + * vendor/bootstrap.min.js, ...) from their license banner, a version marker in the + * code or a versioned file name. Each detection becomes an npm package in the + * inventory, so it gets the same vulnerability and end-of-life checks as lock files. + */ + +const V = '(\\d+\\.\\d+\\.\\d+)'; + +/** + * npm: package name used for advisories; eol: endoflife.date product (optional); + * banner: regexes whose first group is the version; marker+version: both must match. + */ +const LIBRARIES = [ + { npm: 'jquery', label: 'jQuery', eol: 'jquery', banner: [new RegExp(`/\\*!?\\s*jQuery v${V}\\s*\\|`), new RegExp(`jQuery JavaScript Library v${V}`)], file: new RegExp(`^jquery[-.]v?${V}(?:\\.slim)?(?:\\.min)?\\.js$`, 'i') }, + { npm: 'jquery-ui', label: 'jQuery UI', banner: [new RegExp(`jQuery UI (?:- )?v?${V}`)], file: new RegExp(`^jquery-ui[-.]v?${V}(?:\\.custom)?(?:\\.min)?\\.js$`, 'i') }, + { npm: 'bootstrap', label: 'Bootstrap', eol: 'bootstrap', banner: [new RegExp(`Bootstrap v${V} \\(https?://getbootstrap\\.com`)], file: new RegExp(`^bootstrap[-.]v?${V}(?:\\.bundle)?(?:\\.min)?\\.js$`, 'i') }, + { npm: 'angular', label: 'AngularJS', eol: 'angularjs', banner: [new RegExp(`@license AngularJS v${V}`)], file: /^angular[-.]v?(1\.\d+\.\d+)(?:\.min)?\.js$/i }, + { npm: 'lodash', label: 'Lodash', banner: [new RegExp(`\\* lodash ${V}`, 'i')], marker: /@license\s*\n?\s*\*?\s*Lodash\b/, version: [new RegExp(`\\bVERSION\\s*=\\s*['"]${V}['"]`)] }, + { npm: 'underscore', label: 'Underscore.js', banner: [new RegExp(`^\\s*(?://|\\*)\\s*Underscore\\.js ${V}`, 'm')], marker: /\.VERSION\s*=\s*['"]\d|VERSION\s*=\s*['"]\d/, version: [new RegExp(`_\\.VERSION\\s*=\\s*['"]${V}['"]`)], file: new RegExp(`^underscore[-.]v?${V}(?:\\.min)?\\.js$`, 'i') }, + { npm: 'moment', label: 'Moment.js', banner: [new RegExp(`//! moment\\.js\\s*\\n//! version : ${V}`)], marker: /\.moment\s*=\s*\w+\(\)/, version: [new RegExp(`\\.version\\s*=\\s*"${V}"`)] }, + { npm: 'handlebars', label: 'Handlebars', banner: [new RegExp(`@license\\s+handlebars v${V}`, 'i')], file: new RegExp(`^handlebars[-.]v?${V}(?:\\.runtime)?(?:\\.min)?\\.js$`, 'i') }, + { npm: 'vue', label: 'Vue.js', eol: 'vue', banner: [new RegExp(`Vue\\.js v${V}`)], file: new RegExp(`^vue[-.]v?${V}(?:\\.global)?(?:\\.prod)?(?:\\.min)?\\.js$`, 'i') }, + { npm: 'dompurify', label: 'DOMPurify', banner: [new RegExp(`@license DOMPurify ${V}`)], file: new RegExp(`^purify[-.]v?${V}(?:\\.min)?\\.js$`, 'i') }, + { npm: 'tinymce', label: 'TinyMCE', combine: true, marker: /tinymce|tinyMCE/, version: [/majorVersion:\s*["'](\d+)["'],\s*minorVersion:\s*["'](\d+\.\d+)["']/] }, + { npm: 'knockout', label: 'Knockout', banner: [new RegExp(`Knockout JavaScript library v${V}`)] }, +]; + +const JS_EXT = new Set(['js', 'mjs', 'cjs']); +const MAX_SCAN = 2 * 1024 * 1024; + +function versionFrom(re, text, combine = false) { + const m = re.exec(text); + if (!m) return null; + return combine ? `${m[1]}.${m[2]}` : m[1]; +} + +/** @returns {Array<{npm,label,version,eol}>} libraries recognized in one file */ +function identify(name, text) { + const found = []; + const head = text.length > MAX_SCAN ? text.slice(0, MAX_SCAN) : text; + for (const lib of LIBRARIES) { + let version = null; + for (const re of lib.banner || []) { + version = versionFrom(re, head); + if (version) break; + } + if (!version && lib.marker && lib.marker.test(head)) { + for (const re of lib.version || []) { + version = versionFrom(re, head, lib.combine); + if (version) break; + } + } + if (!version && lib.file) version = versionFrom(lib.file, name); + if (version) found.push({ npm: lib.npm, label: lib.label, version, eol: lib.eol || null }); + } + return found; +} + +/** + * @param {{files:Array}} project + * @param {(f) => string|null} readText + * @returns {Array} inventory packages (ecosystem npm, bundled: true) + */ +function detectBundled(project, readText) { + const out = []; + for (const f of project.files) { + if (!JS_EXT.has(f.ext)) continue; + const text = readText(f); + if (!text) continue; + for (const lib of identify(f.name, text)) { + out.push({ ecosystem: 'npm', name: lib.npm, label: lib.label, version: lib.version, eolProduct: lib.eol, bundled: true, dev: false, file: f.rel, line: 1 }); + } + } + return out; +} + +module.exports = { detectBundled, identify, LIBRARIES }; diff --git a/core/supply/lockfiles.js b/core/supply/lockfiles.js new file mode 100644 index 0000000..4574ff4 --- /dev/null +++ b/core/supply/lockfiles.js @@ -0,0 +1,152 @@ +'use strict'; +/* + * Dependency inventory from lock files: composer.lock, package-lock.json (v1, v2, v3) + * and yarn.lock (classic v1 and berry). Every package records the lock file and line + * it was found on so findings point at a real location. + */ +const fs = require('fs'); +const path = require('path'); + +const LOCK_FILES = new Set(['composer.lock', 'package-lock.json', 'npm-shrinkwrap.json', 'yarn.lock']); + +function lineFinder(text) { + const lines = text.split('\n'); + return (needle, from = 0) => { + for (let i = from; i < lines.length; i++) if (lines[i].includes(needle)) return i + 1; + return null; + }; +} + +function parseComposerLock(text, rel) { + const data = JSON.parse(text); + const find = lineFinder(text); + const out = []; + for (const [key, dev] of [['packages', false], ['packages-dev', true]]) { + for (const p of data[key] || []) { + if (!p || !p.name || !p.version) continue; + out.push({ + ecosystem: 'Packagist', + name: p.name, + version: String(p.version).replace(/^v(?=\d)/, ''), + dev, + abandoned: p.abandoned === undefined || p.abandoned === false ? null : (p.abandoned === true ? true : String(p.abandoned)), + file: rel, + line: find(`"name": "${p.name}"`), + }); + } + } + return out; +} + +function npmNameFromPath(key) { + const i = key.lastIndexOf('node_modules/'); + return i === -1 ? key : key.slice(i + 'node_modules/'.length); +} + +function parsePackageLock(text, rel) { + const data = JSON.parse(text); + const find = lineFinder(text); + const out = []; + if (data.packages && typeof data.packages === 'object') { + // lockfileVersion 2 and 3 + for (const [key, p] of Object.entries(data.packages)) { + if (!key || !p || p.link || !p.version) continue; + if (!key.includes('node_modules/')) continue; // workspace folders + out.push({ ecosystem: 'npm', name: p.name || npmNameFromPath(key), version: p.version, dev: Boolean(p.dev), file: rel, line: find(`"${key}": {`) }); + } + return out; + } + // lockfileVersion 1: nested "dependencies" + const walk = (deps) => { + for (const [name, p] of Object.entries(deps || {})) { + if (!p || !p.version || /^(file|link|git|github):/.test(p.version)) continue; + out.push({ ecosystem: 'npm', name, version: p.version, dev: Boolean(p.dev), file: rel, line: find(`"${name}": {`) }); + walk(p.dependencies); + } + }; + walk(data.dependencies); + return out; +} + +function yarnName(spec) { + const s = spec.trim().replace(/^"|"$/g, ''); + const at = s.indexOf('@', 1); + return at === -1 ? s : s.slice(0, at); +} + +function parseYarnLock(text, rel) { + const out = []; + const lines = text.split('\n'); + let current = null; + for (let i = 0; i < lines.length; i++) { + const l = lines[i].replace(/\r$/, ''); + if (!l.trim() || l.startsWith('#')) continue; + if (!/^\s/.test(l) && l.endsWith(':')) { + const specs = l.slice(0, -1).split(/,\s*/); + const name = yarnName(specs[0]); + current = name === '__metadata' ? null : { name, line: i + 1 }; + if (current && /@(workspace|link|portal|file|patch):/.test(specs[0])) current = null; + continue; + } + const m = current && /^\s+version:?\s+"?([^"\s]+)"?/.exec(l); + if (m) { + out.push({ ecosystem: 'npm', name: current.name, version: m[1], dev: false, file: rel, line: current.line }); + current = null; + } + } + return out; +} + +/** Composer's vendor/composer/installed.json tells whether require-dev packages were installed. */ +function composerDevInstall(projectRoot, lockRel) { + const dir = path.join(projectRoot, path.dirname(lockRel)); + const file = path.join(dir, 'vendor', 'composer', 'installed.json'); + let data; + try { + data = JSON.parse(fs.readFileSync(file, 'utf8')); + } catch { + return null; + } + if (Array.isArray(data)) return null; // Composer 1 format has no dev marker + const names = Array.isArray(data['dev-package-names']) ? data['dev-package-names'] : []; + if (data.dev === true && names.length) return { file: path.posix.join(path.posix.dirname(lockRel) === '.' ? '' : path.posix.dirname(lockRel), 'vendor/composer/installed.json'), names }; + return null; +} + +/** + * @param {{root:string, files:Array<{rel,name,abs}>}} project + * @param {(f) => string|null} readText + * @returns {{packages:Array, lockFiles:string[], errors:string[], devInstalls:Array, manifestsWithoutLock:string[]}} + */ +function readLockFiles(project, readText) { + const packages = []; + const lockFiles = []; + const errors = []; + const devInstalls = []; + const dirsWithLock = new Set(); + for (const f of project.files) { + if (!LOCK_FILES.has(f.name)) continue; + const text = readText(f); + if (text === null || text === undefined) continue; + try { + let list = []; + if (f.name === 'composer.lock') { + list = parseComposerLock(text, f.rel); + const dev = composerDevInstall(project.root, f.rel); + if (dev) devInstalls.push({ lock: f.rel, ...dev }); + } else if (f.name === 'yarn.lock') list = parseYarnLock(text, f.rel); + else list = parsePackageLock(text, f.rel); + packages.push(...list); + lockFiles.push(f.rel); + dirsWithLock.add(`${path.posix.dirname(f.rel)}|${f.name === 'composer.lock' ? 'composer' : 'npm'}`); + } catch (err) { + errors.push(`${f.rel}: ${err.message}`); + } + } + const manifestsWithoutLock = project.files + .filter((f) => (f.name === 'composer.json' || f.name === 'package.json') && !dirsWithLock.has(`${path.posix.dirname(f.rel)}|${f.name === 'composer.json' ? 'composer' : 'npm'}`)) + .map((f) => f.rel); + return { packages, lockFiles, errors, devInstalls, manifestsWithoutLock }; +} + +module.exports = { readLockFiles, parseComposerLock, parsePackageLock, parseYarnLock, LOCK_FILES }; diff --git a/core/supply/osv.js b/core/supply/osv.js new file mode 100644 index 0000000..b1c8c14 --- /dev/null +++ b/core/supply/osv.js @@ -0,0 +1,143 @@ +'use strict'; +/* + * Vulnerability lookups against OSV.dev (https://osv.dev), used only with --online. + * Only ecosystem, package name and version are sent. Answers are cached for 24 hours + * in the ASST cache folder. + */ +const fs = require('fs'); +const path = require('path'); +const http = require('../http'); +const { affectedBy, compare } = require('./semver'); + +const API = 'https://api.osv.dev/v1'; +const TTL_MS = 24 * 60 * 60 * 1000; +const BATCH = 500; +const SEVERITY = { CRITICAL: 'critical', HIGH: 'high', MODERATE: 'medium', MEDIUM: 'medium', LOW: 'low' }; + +const keyOf = (p) => `${p.ecosystem}|${p.name}|${p.version}`; + +/** Reduces an OSV record to what the report needs, for one package. */ +function compact(v, ecosystem, name) { + const affected = (v.affected || []).filter((a) => a.package && a.package.ecosystem === ecosystem && a.package.name.toLowerCase() === name.toLowerCase()); + const ranges = []; + const versions = []; + for (const a of affected) { + for (const r of a.ranges || []) if (r.type === 'SEMVER' || r.type === 'ECOSYSTEM') ranges.push(r.events || []); + versions.push(...(a.versions || [])); + } + const ds = v.database_specific || {}; + const summary = (v.summary || String(v.details || '').split(/\.\s|\n/)[0] || '').trim().slice(0, 200); + return { + id: v.id, + aliases: (v.aliases || []).filter((a) => /^CVE-\d+-\d+$/.test(a)), + summary, + severity: SEVERITY[String(ds.severity || '').toUpperCase()] || null, + cwe: Array.isArray(ds.cwe_ids) ? ds.cwe_ids.slice(0, 3) : [], + ranges, + versions: versions.length > 200 ? [] : versions, + }; +} + +/** True when the compact advisory covers this version. */ +function affects(adv, version) { + if (adv.versions && adv.versions.includes(version)) return true; + return adv.ranges.some((events) => affectedBy(version, events)); +} + +/** Smallest fixed version above `version` for one advisory, or null. */ +function fixedFor(adv, version) { + let best = null; + for (const events of adv.ranges) { + for (const ev of events) { + if (ev.fixed !== undefined && compare(ev.fixed, version) > 0 && (!best || compare(ev.fixed, best) < 0)) best = ev.fixed; + } + } + return best; +} + +function readCache(file) { + try { + const data = JSON.parse(fs.readFileSync(file, 'utf8')); + return { queries: data.queries || {}, vulns: data.vulns || {} }; + } catch { + return { queries: {}, vulns: {} }; + } +} + +function writeCache(file, data) { + try { + fs.mkdirSync(path.dirname(file), { recursive: true }); + fs.writeFileSync(file, JSON.stringify(data)); + } catch { + // a read-only ASST folder (for example in a container) only disables the cache + } +} + +/** + * @param {Array<{ecosystem,name,version}>} packages (npm and Packagist are queried) + * @param {{cacheFile?:string, now?:number, client?:{postJson,getJson}}} opts + * @returns {Promise>} package key -> advisories affecting it + */ +async function lookup(packages, opts = {}) { + const client = opts.client || http; + const now = opts.now || Date.now(); + const cache = opts.cacheFile ? readCache(opts.cacheFile) : { queries: {}, vulns: {} }; + const fresh = (entry) => entry && now - entry.at < TTL_MS; + + const unique = []; + const seen = new Set(); + for (const p of packages) { + if (p.ecosystem !== 'npm' && p.ecosystem !== 'Packagist') continue; + const k = keyOf(p); + if (seen.has(k)) continue; + seen.add(k); + unique.push(p); + } + + const pending = unique.filter((p) => !fresh(cache.queries[keyOf(p)])); + for (let i = 0; i < pending.length; i += BATCH) { + const chunk = pending.slice(i, i + BATCH); + const res = await client.postJson(`${API}/querybatch`, { + queries: chunk.map((p) => ({ package: { ecosystem: p.ecosystem, name: p.name }, version: p.version })), + }, { timeoutMs: 30000 }); + (res.results || []).forEach((r, j) => { + cache.queries[keyOf(chunk[j])] = { at: now, ids: (r.vulns || []).map((v) => v.id) }; + }); + } + + const ids = [...new Set(unique.flatMap((p) => (cache.queries[keyOf(p)] || { ids: [] }).ids))]; + const missing = ids.filter((id) => !fresh(cache.vulns[id])); + await http.mapLimit(missing, 6, async (id) => { + const v = await client.getJson(`${API}/vulns/${encodeURIComponent(id)}`, { timeoutMs: 30000 }); + cache.vulns[id] = { at: now, raw: { id: v.id, summary: v.summary, details: String(v.details || '').slice(0, 400), aliases: v.aliases, affected: v.affected, database_specific: v.database_specific } }; + }); + + const out = new Map(); + for (const p of unique) { + const list = []; + for (const id of (cache.queries[keyOf(p)] || { ids: [] }).ids) { + const entry = cache.vulns[id]; + if (entry) list.push(compact(entry.raw, p.ecosystem, p.name)); + } + out.set(keyOf(p), list); + } + if (opts.cacheFile) writeCache(opts.cacheFile, cache); + return out; +} + +/** Queries every advisory of one package (used to build the bundled offline data). */ +async function allAdvisories(ecosystem, name, client = http) { + const out = []; + let pageToken; + do { + const res = await client.postJson(`${API}/query`, { package: { ecosystem, name }, ...(pageToken ? { page_token: pageToken } : {}) }, { timeoutMs: 30000 }); + for (const v of res.vulns || []) { + if (v.withdrawn) continue; + out.push(compact(v, ecosystem, name)); + } + pageToken = res.next_page_token; + } while (pageToken); + return out.sort((a, b) => a.id.localeCompare(b.id)); +} + +module.exports = { lookup, allAdvisories, compact, affects, fixedFor, keyOf, API }; diff --git a/core/supply/semver.js b/core/supply/semver.js new file mode 100644 index 0000000..0e2e498 --- /dev/null +++ b/core/supply/semver.js @@ -0,0 +1,53 @@ +'use strict'; +/* + * Lenient version comparison for npm/Packagist/bundled-library versions and OSV ranges. + * Handles a leading "v", any number of numeric parts and pre-release suffixes. + */ + +function parse(v) { + const s = String(v || '').trim().replace(/^[vV=]/, ''); + const m = /^(\d+(?:\.\d+)*)(?:[-.]?([0-9A-Za-z.-]+))?(?:\+.*)?$/.exec(s); + if (!m) return null; + const nums = m[1].split('.').map(Number); + const pre = m[2] || ''; + return { nums, pre: /^(p|patch|pl)\d*$/i.test(pre) ? '' : pre }; +} + +/** -1, 0 or 1. Unparsable versions compare equal (callers treat that as "unknown"). */ +function compare(a, b) { + const x = parse(a); + const y = parse(b); + if (!x || !y) return 0; + const n = Math.max(x.nums.length, y.nums.length); + for (let i = 0; i < n; i++) { + const d = (x.nums[i] || 0) - (y.nums[i] || 0); + if (d) return d < 0 ? -1 : 1; + } + if (x.pre && !y.pre) return -1; + if (!x.pre && y.pre) return 1; + if (x.pre === y.pre) return 0; + return x.pre < y.pre ? -1 : 1; +} + +/** + * OSV-style range events: [{introduced}, {fixed}|{last_affected}], applied in order. + * @returns {boolean} true when version is affected by the range + */ +function affectedBy(version, events) { + if (!parse(version)) return false; + let affected = false; + for (const ev of events || []) { + if (ev.introduced !== undefined) { + if (ev.introduced === '0' || compare(version, ev.introduced) >= 0) affected = true; + } else if (ev.fixed !== undefined) { + if (compare(version, ev.fixed) >= 0) affected = false; + } else if (ev.last_affected !== undefined) { + if (compare(version, ev.last_affected) > 0) affected = false; + } else if (ev.limit !== undefined && compare(version, ev.limit) >= 0) { + affected = false; + } + } + return affected; +} + +module.exports = { parse, compare, affectedBy }; diff --git a/core/suppress.js b/core/suppress.js new file mode 100644 index 0000000..f815042 --- /dev/null +++ b/core/suppress.js @@ -0,0 +1,86 @@ +'use strict'; +/* + * Finding suppression and baseline comparison. + * + * Inline suppression (any comment syntax), on the finding's line or the line above: + * $x = $db->query($sql); // asst-ignore[PHP-SQLI-001] value comes from an allow-list + * # asst-ignore (suppresses every rule on the next line) + * + * Path suppression: an .asstignore file at the scanned root (one glob per line). + * + * Baseline: a JSON file of fingerprints from an earlier scan. Findings are marked + * "new" or "unchanged", and baseline entries that disappeared are reported as fixed. + */ +const fs = require('fs'); + +const INLINE_RE = /asst-ignore(?:\[([^\]]*)\])?/i; + +function parseInline(lineText) { + const m = INLINE_RE.exec(lineText || ''); + if (!m) return null; + const rules = (m[1] || '').split(',').map((s) => s.trim()).filter(Boolean); + return { rules }; +} + +function covers(directive, ruleId) { + return directive && (directive.rules.length === 0 || directive.rules.includes(ruleId)); +} + +/** True if the finding is suppressed by an inline directive. getLine(n) returns 1-based line text. */ +function isSuppressedInline(finding, getLine) { + if (!finding.line) return false; + if (covers(parseInline(getLine(finding.line)), finding.ruleId)) return true; + // directive on the preceding line, when that line is only a comment + const prev = getLine(finding.line - 1); + const directive = parseInline(prev); + if (directive && /^\s*(\/\/|#|\/\*|\*|', i)) { st.m = 'text'; i += 2; } + break; + default: + st.m = 'text'; + } + } + return st; +} + +function htmlContext(st) { + switch (st.m) { + case 'text': + if (st.raw === 'script') { + if (st.jsq && st.jsEval) return { kind: 'js-code' }; + return st.jsq ? { kind: 'js-string', quote: st.jsq } : { kind: 'js-code' }; + } + if (st.raw === 'style') return { kind: 'css' }; + if (st.raw) return { kind: 'rcdata' }; + return { kind: 'html' }; + case 'tagname': case 'attrs': case 'attrname': case 'aftername': + return { kind: 'tag' }; + case 'beforevalue': case 'uq': + return { kind: 'attr-unquoted', attr: st.attr.toLowerCase() }; + case 'dq': case 'sq': { + const quote = st.m === 'dq' ? '"' : "'"; + const attr = st.attr.toLowerCase(); + if (/^on/.test(attr)) return { kind: 'js-attr', quote, jsq: st.jsq }; + if (attr === 'style') return { kind: 'css' }; + if (URL_ATTRS.has(attr) && st.val.trim() === '') return { kind: 'url-attr', quote }; + return { kind: 'attr', quote }; + } + case 'comment': + return { kind: 'comment' }; + default: + return { kind: 'html' }; + } +} + +const htmlEncoded = (v) => Boolean(v.enc && v.enc.html); +const htmlQuotesEncoded = (v) => Boolean(v.enc && v.enc.html && v.enc.htmlQuotes !== false); + +function htmlSafe(v, ctx) { + if (safeScalar(v)) return true; + switch (ctx.kind) { + case 'html': case 'rcdata': + return htmlEncoded(v) || excludes(v, '<'); + case 'attr': + return (ctx.quote === '"' ? htmlEncoded(v) : htmlQuotesEncoded(v)) || excludes(v, ctx.quote); + case 'url-attr': + return (Boolean(v.enc && v.enc.url) || excludes(v, ':')) && (htmlQuotesEncoded(v) || excludes(v, ctx.quote)); + case 'attr-unquoted': + return within(v, `${WORD}.-`); + case 'js-string': + return htmlQuotesEncoded(v) || excludes(v, `${ctx.quote}\\<\n\r`); + case 'js-attr': + if (ctx.jsq) return excludes(v, `${ctx.quote}${ctx.jsq}\\&`); + return within(v, WORD); + case 'comment': + return excludes(v, '-!>'); + case 'tag': case 'js-code': case 'css': + return within(v, WORD); + default: + return htmlEncoded(v); + } +} + +/** + * Checks an output value against the current HTML state. + * @returns {{unsafe:Array, state:object}} unsafe segments and the state after output + */ +function html(value, state) { + const st = { ...(state || initialHtmlState()) }; + const unsafe = []; + for (const seg of segmentsOf(value)) { + if (seg.text !== undefined) { htmlScan(st, seg.text); continue; } + if (!seg.v || !seg.v.t) continue; + const ctx = htmlContext(st); + if (!htmlSafe(seg.v, ctx)) unsafe.push({ v: seg.v, context: ctx.kind + (ctx.quote ? ` ${ctx.quote}` : '') }); + if (st.m === 'beforevalue') { st.m = 'uq'; st.val = 'x'; } + if ((st.m === 'dq' || st.m === 'sq' || st.m === 'uq') && st.val === '') st.val = 'x'; + } + return { unsafe, state: st }; +} + +module.exports = { + sql, xpath, shell, code, ldap, path, any, crlf, urlControl, html, htmlScan, htmlContext, htmlSafe, + initialHtmlState, DIGITS, NUMERIC, LETTERS, WORD, +}; diff --git a/core/taint/interpreter.js b/core/taint/interpreter.js new file mode 100644 index 0000000..8d4a732 --- /dev/null +++ b/core/taint/interpreter.js @@ -0,0 +1,912 @@ +'use strict'; +/* + * Abstract interpreter for taint analysis over a small language-independent IR. + * + * Program: { main: Stmt[], functions: Map, classes: Map, + * methodsByName: Map, allFunctions: Fn[] } + * Fn: { id, name, params: [{name, byRef, def: Expr|null, variadic}], body: Stmt[], cls, line } + * Cls: { name, parent, methods: Map, props: [{name, def: Expr|null}] } + * + * Stmt kinds: assign{target, expr, op}, expr{expr}, if{test, then, else}, loop{init, test, body, + * update, each:{source, key, value}}, switch{test, cases:[{test, body}]}, try{body, catches:[{target, body}], fin}, + * return{expr}, halt{}, global{names}, unset{targets}, block{body} + * LValue: {k:'path', base, segs:[{key: string|'*'|null} | {prop: string}]} | {k:'list', items:[{key, target}]} | {k:'none'} + * Expr kinds: lit{value}, path (read), concat{parts}, call{callee, args, recv}, new{cls, args}, + * cast{type, expr}, ternary{test, then, else}, bin{op, left, right}, unary{op, expr}, + * array{items:[{key, value, unpack}]}, assign{target, expr, op}, closure{fn}, unknown{parts} + * + * The language catalog supplies sources, sinks, sanitizers, propagators and guards. + * Every node carries `line` (and `col` where useful). + */ +const V = require('./value'); +const contexts = require('./contexts'); + +const MAX_DEPTH = 5; +const LOOP_ROUNDS = 3; + +class Env { + constructor(vars, out) { + this.vars = vars || new Map(); + this.out = out || contexts.initialHtmlState(); + this.bottom = false; + this.globals = null; // Set of names bound to the main environment + this.included = null; // files already included (for *_once) + this.haltKind = null; // 'exit' | 'return' + } + + clone() { + const e = new Env(new Map(this.vars), { ...this.out }); + e.bottom = this.bottom; + e.globals = this.globals ? new Set(this.globals) : null; + e.included = this.included ? new Set(this.included) : null; + e.haltKind = this.haltKind; + return e; + } + + /** Joins another environment into this one (control-flow merge). */ + joinFrom(other) { + if (other.bottom) return this; + if (this.bottom) { + this.vars = new Map(other.vars); + this.out = { ...other.out }; + this.bottom = false; + this.globals = other.globals ? new Set(other.globals) : null; + this.included = other.included ? new Set(other.included) : null; + this.haltKind = null; + return this; + } + for (const [k, v] of other.vars) this.vars.set(k, this.vars.has(k) ? V.join(this.vars.get(k), v) : v); + for (const [k, v] of this.vars) if (!other.vars.has(k)) this.vars.set(k, v); + if (JSON.stringify(this.out) !== JSON.stringify(other.out)) this.out = contexts.initialHtmlState(); + if (other.globals) this.globals = new Set([...(this.globals || []), ...other.globals]); + if (other.included) this.included = new Set([...(this.included || []), ...other.included]); + return this; + } + + sameAs(other) { + if (this.bottom !== other.bottom || this.vars.size !== other.vars.size) return false; + for (const [k, v] of this.vars) { + const o = other.vars.get(k); + if (!o || o.t !== v.t || o.c !== v.c || o.str !== v.str || Boolean(o.arr) !== Boolean(v.arr)) return false; + } + return true; + } +} + +/** Source-like text of an access path; `style` comes from the language catalog. */ +function pathText(t, style = {}) { + if (!t || t.k !== 'path') return 'a variable'; + const prefix = style.varPrefix !== undefined ? style.varPrefix : '$'; + const prop = style.prop || '->'; + const dotKeys = Boolean(style.dotKeys); + return `${prefix}${t.base}${t.segs.map((s) => { + if (s.prop !== undefined) return `${prop}${s.prop}`; + if (dotKeys && typeof s.key === 'string' && /^[A-Za-z_$][\w$]*$/.test(s.key)) return `.${s.key}`; + return `[${s.key === null || s.key === '*' ? '' : JSON.stringify(s.key)}]`; + }).join('')}`; +} + +/** Signature of the tainted variables a closure captured (part of the memo key). */ +function captureSignature(env) { + if (!env) return ''; + const parts = []; + for (const [k, v] of env.vars) if (v && v.t) parts.push(`${k}:${v.c}${v.g ? 'g' : ''}`); + return parts.sort().join(','); +} + +function signature(values) { + return values.map((v) => { + if (!v) return '-'; + if (!v.t) return v.obj ? `o:${v.obj.cls}:${[...v.obj.fields.entries()].map(([k, f]) => `${k}=${f.t ? 1 : 0}`).join(',')}` : (v.str !== undefined ? `s${v.str.length}` : (v.arr ? `a${v.arr.size}` : 'c')); + return `t${v.c}${v.g ? 'g' : ''}${v.allowed === null || v.allowed === undefined ? '*' : v.allowed.length}${Object.keys(v.enc || {}).sort().join('')}${v.obj ? 'o' : ''}`; + }).join('|'); +} + +class Interpreter { + /** + * @param {object} program IR program + * @param {object} catalog language catalog (see langs/php/taint/catalog.js) + * @param {{secondOrder?:boolean, budget?:number, assumeParamsTainted?:boolean}} options + */ + constructor(program, catalog, options = {}) { + this.p = program; + this.cat = catalog; + this.opts = options; + const shared = options.shared || {}; + this.hits = shared.hits || new Map(); + this.memo = shared.memo || new Map(); + this.analyzed = shared.analyzed || new Set(); + this.hitLog = []; + this.project = options.project || null; + this.entry = program.file; + this.constants = new Map(); + this.includeCount = 0; + this.depth = 0; + this.budget = options.budget || 400000; + this.mainEnv = null; + this.mainEnvs = shared.mainEnvs || new Map(); // file -> module scope after running it (for closures) + this.style = (catalog && catalog.style) || {}; + this.exhausted = false; + } + + run({ standalone = true } = {}) { + const env = new Env(); + this.mainEnv = env; + // module scopes are kept only for languages whose functions close over them (JavaScript) + if (this.cat.capturesScope) this.mainEnvs.set(this.p.file, env); + this.execBlock(this.p.main, env, { fn: null, file: this.p.file }); + if (standalone) this.analyzeRemaining(this.p.allFunctions); + return { hits: [...this.hits.values()], exhausted: this.exhausted }; + } + + /** + * Analyzes functions that were never called. Parameters are untainted unless the catalog knows + * the function is an entry point (for example a web request handler) or assumeParamsTainted is set. + * Functions that capture their scope (JavaScript) see the module scope of their file. + */ + analyzeRemaining(functions) { + for (const fn of functions) { + if (this.analyzed.has(fn)) continue; + let args = this.opts.assumeParamsTainted + ? fn.params.map((p) => V.source('src', `parameter ${this.style.varPrefix !== undefined ? this.style.varPrefix : '$'}${p.name}`, fn.line, 2)) + : []; + const entry = this.cat.entryArgs ? this.cat.entryArgs(fn, this.opts) : null; + if (entry) args = entry; + const thisVal = fn.cls ? this.newObjectValue(fn.cls, false) : null; + const captured = fn.captures ? this.mainEnvs.get(fn.file) || null : null; + this.invoke(fn, args, [], thisVal, fn.line, captured); + } + } + + tick() { + if (--this.budget <= 0) { this.exhausted = true; return false; } + return true; + } + + /* ----------------------------------------------------------- statements */ + + execBlock(stmts, env, f) { + for (const s of stmts || []) { + if (env.bottom || !this.tick()) return; + this.exec(s, env, f); + } + } + + exec(s, env, f) { + switch (s.k) { + case 'assign': { + let v = this.eval(s.expr, env, f); + if (s.op === '.=') v = V.concat([this.read(s.target, env, f), v]); + else if (s.op === '??=') v = V.join(this.read(s.target, env, f), v); + else if (s.op && s.op !== '=') v = { t: false, num: true }; + this.write(s.target, v.t ? V.step(v, s.line, `assigned to ${pathText(s.target, this.style)}`) : v, env, f, s.line); + break; + } + case 'expr': + this.eval(s.expr, env, f); + break; + case 'if': { + if (s.test) this.eval(s.test, env, f); + const truth = this.constTruth(s.test); + const thenEnv = env.clone(); + const elseEnv = env.clone(); + if (truth === false) thenEnv.bottom = true; + else this.refine(s.test, thenEnv, f, true); + if (truth === true) elseEnv.bottom = true; + else this.refine(s.test, elseEnv, f, false); + this.execBlock(s.then, thenEnv, f); + this.execBlock(s.else, elseEnv, f); + this.replace(env, thenEnv.joinFrom(elseEnv)); + break; + } + case 'loop': { + this.execBlock(s.init, env, f); + const entry = env.clone(); + let state = env.clone(); + for (let round = 0; round < LOOP_ROUNDS; round++) { + const body = state.clone(); + if (s.each) this.bindEach(s.each, body, f, s.line); + if (s.test) this.eval(s.test, body, f); + if (s.test) this.refine(s.test, body, f, true); + this.execBlock(s.body, body, f); + this.execBlock(s.update, body, f); + body.bottom = false; // break/continue/return inside loops are approximated + const next = state.clone().joinFrom(body); + if (next.sameAs(state)) { state = next; break; } + state = next; + } + this.replace(env, entry.joinFrom(state)); + break; + } + case 'switch': { + const test = s.test ? this.eval(s.test, env, f) : null; + const result = new Env(); + result.bottom = true; + let hasDefault = false; + for (const c of s.cases) { + const arm = env.clone(); + if (c.test === null) hasDefault = true; + else if (s.test && s.test.k === 'path' && c.test.k === 'lit') this.write(s.test, V.constant(c.test.value), arm, f, c.line); + this.execBlock(c.body, arm, f); + arm.bottom = false; // break + result.joinFrom(arm); + } + if (!hasDefault) result.joinFrom(env); + void test; + this.replace(env, result); + break; + } + case 'try': { + const entry = env.clone(); + this.execBlock(s.body, env, f); + const afterTry = env.clone(); + const catchStart = entry.clone().joinFrom(afterTry); + catchStart.bottom = false; + const merged = afterTry.clone(); + for (const c of s.catches) { + const ce = catchStart.clone(); + if (c.target) this.write(c.target, V.CLEAN, ce, f, c.line); + this.execBlock(c.body, ce, f); + merged.joinFrom(ce); + } + this.replace(env, merged); + if (s.fin) { + const wasBottom = env.bottom; + env.bottom = false; + this.execBlock(s.fin, env, f); + env.bottom = env.bottom || wasBottom; + } + break; + } + case 'return': { + const v = s.expr ? this.eval(s.expr, env, f) : V.CLEAN; + if (f.fn) { + f.ret = f.ret ? V.join(f.ret, v) : v; + this.recordExit(env, f); + } + env.bottom = true; + env.haltKind = f.fn ? 'return' : 'top-return'; + break; + } + case 'halt': + if (f.fn) this.recordExit(env, f); + env.bottom = true; + env.haltKind = 'exit'; + break; + case 'global': + env.globals = env.globals || new Set(); + for (const n of s.names) env.globals.add(n); + break; + case 'unset': + for (const t of s.targets) this.write(t, V.CLEAN, env, f, s.line); + break; + case 'block': + this.execBlock(s.body, env, f); + break; + default: + break; + } + } + + replace(env, other) { + env.vars = other.vars; + env.out = other.out; + env.bottom = other.bottom; + env.globals = other.globals; + env.included = other.included; + env.haltKind = other.haltKind; + } + + recordExit(env, f) { + const thisNow = env.vars.get('this'); + if (thisNow) f.thisOut = f.thisOut ? V.join(f.thisOut, thisNow) : thisNow; + if (f.byRefParams) { + for (const name of f.byRefParams) { + const v = env.vars.get(name) || V.CLEAN; + f.byRefOut.set(name, f.byRefOut.has(name) ? V.join(f.byRefOut.get(name), v) : v); + } + } + } + + bindEach(each, env, f, line) { + const src = this.eval(each.source, env, f); + let element; + if (src.arr && src.arr.size) element = V.joinAll([...src.arr.values()]); + else element = src.t ? src : V.CLEAN; + if (src.t && !src.arr) element = src; + if (each.value) this.write(each.value, element, env, f, line); + if (each.key) this.write(each.key, each.taintedKeys && src.t ? V.step(src, line, 'array key') : V.CLEAN, env, f, line); + } + + constTruth(test) { + if (!test) return null; + if (test.k === 'lit') { + if (test.value === false || test.value === 0 || test.value === '' || test.value === null || test.value === '0') return false; + return true; + } + return null; + } + + /* ----------------------------------------------------------- refinement */ + + refine(test, env, f, positive) { + if (!test) return; + if (test.k === 'unary' && test.op === '!') { this.refine(test.expr, env, f, !positive); return; } + if (test.k === 'bin') { + const { op, left, right } = test; + if ((op === '&&' || op === 'and') && positive) { this.refine(left, env, f, true); this.refine(right, env, f, true); return; } + if ((op === '||' || op === 'or') && !positive) { this.refine(left, env, f, false); this.refine(right, env, f, false); return; } + if (['==', '===', '!=', '!==', '<>'].includes(op)) { + const eq = op === '==' || op === '==='; + const litSide = left.k === 'lit' ? left : (right.k === 'lit' ? right : null); + const other = litSide === left ? right : left; + if (litSide && other) { + if (other.k === 'path' && eq === positive && typeof litSide.value === 'string') { + this.write(other, V.constant(litSide.value), env, f, test.line); + return; + } + if (other.k === 'call') { + const truthy = !(litSide.value === false || litSide.value === 0 || litSide.value === null || litSide.value === '0'); + this.refine(other, env, f, (eq === positive) ? truthy : !truthy); + return; + } + } + } + if (['>', '>='].includes(op) && left.k === 'call' && right.k === 'lit' && positive) { this.refine(left, env, f, true); return; } + return; + } + if (test.k === 'call' && positive) { + const g = this.cat.guard ? this.cat.guard(test, (e) => this.eval(e, env.clone(), f)) : null; + if (g && g.target && g.target.k === 'path') { + const cur = this.read(g.target, env, f); + if (!cur.t) return; + let next; + if (g.effect.clean) next = g.effect.num ? { t: false, num: true } : V.CLEAN; + else if (g.effect.allowed !== undefined) next = V.sanitize(cur, { allowed: g.effect.allowed }, test.line, g.note); + else if (g.effect.guarded) next = { ...V.step(cur, test.line, g.note), g: true, c: 2 }; + if (next) this.write(g.target, next, env, f, test.line); + } + } + } + + /* ------------------------------------------------------------ variables */ + + envFor(base, env) { + if (env.globals && env.globals.has(base) && this.mainEnv && env !== this.mainEnv) return this.mainEnv; + return env; + } + + read(target, env, f) { + if (!target || target.k !== 'path') return V.CLEAN; + let base; + const scope = this.envFor(target.base, env); + if (scope.vars.has(target.base)) base = scope.vars.get(target.base); + else if (target.base === 'GLOBALS' && target.segs.length && target.segs[0].key && target.segs[0].key !== '*') { + return this.read({ k: 'path', base: target.segs[0].key, segs: target.segs.slice(1), line: target.line }, this.mainEnv || env, f); + } else { + const sg = this.cat.superglobal ? this.cat.superglobal(target.base, target.segs, target.line, this.opts) : undefined; + if (sg !== undefined) return sg; + base = undefined; + } + if (base === undefined) return V.CLEAN; + let v = base; + for (const seg of target.segs) { + v = this.descend(v, seg); + if (!v) return V.CLEAN; + } + return v; + } + + descend(v, seg) { + if (seg.prop !== undefined) { + if (v.obj) return v.obj.fields.get(seg.prop) || (v.t ? v : V.CLEAN); + return v.t ? v : V.CLEAN; + } + if (v.arr) { + if (seg.key === '*' || seg.key === null) return v.arr.size ? V.joinAll([...v.arr.values()]) : (v.t ? v : V.CLEAN); + const exact = v.arr.get(seg.key); + if (exact) return exact; + const wild = v.arr.get('*'); + if (wild) return wild; + return v.t && !v.arr.size ? v : V.CLEAN; + } + if (v.t) { + const out = { ...v }; + delete out.segs; + return out; + } + return V.CLEAN; + } + + write(target, value, env, f, line) { + if (!target) return; + if (target.k === 'list') { + const src = value || V.CLEAN; + target.items.forEach((item, idx) => { + if (!item || !item.target) return; + const key = item.key !== null && item.key !== undefined ? String(item.key) : String(idx); + this.write(item.target, this.descend(src, { key }), env, f, line); + }); + return; + } + if (target.k !== 'path') return; + const scope = this.envFor(target.base, env); + if (target.segs.length === 0) { + scope.vars.set(target.base, value || V.CLEAN); + return; + } + const cur = scope.vars.has(target.base) ? scope.vars.get(target.base) : undefined; + scope.vars.set(target.base, this.update(cur, target.segs, value || V.CLEAN, 0)); + } + + update(cur, segs, value, depth) { + const seg = segs[0]; + const rest = segs.slice(1); + const base = cur ? { ...cur } : { t: false }; + if (seg.prop !== undefined) { + const fields = new Map(base.obj ? base.obj.fields : []); + const prev = fields.get(seg.prop); + fields.set(seg.prop, rest.length && depth < 4 ? this.update(prev, rest, value, depth + 1) : value); + base.obj = { cls: base.obj ? base.obj.cls : null, fields }; + return base; + } + const arr = new Map(base.arr || []); + let key = seg.key; + if (key === null) { // $a[] = push + let i = 0; + while (arr.has(String(i))) i++; + key = String(i); + } + const prev = arr.get(key); + const nextVal = rest.length && depth < 4 ? this.update(prev, rest, value, depth + 1) : value; + if (key === '*') { + // dynamic key: any existing entry may have been overwritten + for (const [k, v] of arr) if (k !== '*') arr.set(k, V.join(v, nextVal)); + arr.set('*', prev ? V.join(prev, nextVal) : nextVal); + } else { + arr.set(key, nextVal); + } + const out = V.joinAll([...arr.values()]); + const res = { ...out, arr }; + if (base.obj) res.obj = base.obj; + if (!res.t) { delete res.segs; } + return res; + } + + /* ---------------------------------------------------------- expressions */ + + eval(e, env, f) { + if (!e || !this.tick()) return V.CLEAN; + switch (e.k) { + case 'lit': + if (typeof e.value === 'number') return { t: false, num: true, str: String(e.value) }; + if (typeof e.value === 'string') return V.constant(e.value); + return V.CLEAN; + case 'const': + if (this.constants.has(e.name)) return this.constants.get(e.name); + return this.cat.constant ? this.cat.constant(e.name) : V.CLEAN; + case 'magic': { + const file = f.file || this.p.file || ''; + const dir = file.includes('/') ? file.slice(0, file.lastIndexOf('/')) : ''; + if (e.name === '__DIR__') return V.constant(dir ? `/${dir}` : ''); + if (e.name === '__FILE__') return V.constant(`/${file}`); + if (e.name === '__LINE__') return { t: false, num: true }; + return V.constant(e.name); + } + case 'path': + if (e.base === 'this' && f.fn && !env.vars.has('this')) return V.CLEAN; + return this.read(e, env, f); + case 'concat': + return V.concat(e.parts.map((p) => this.eval(p, env, f))); + case 'cast': { + const v = this.eval(e.expr, env, f); + if (['int', 'integer', 'float', 'double', 'bool', 'boolean', 'real'].includes(e.type)) return { t: false, num: true }; + if (e.type === 'unset') return V.CLEAN; + return v; + } + case 'ternary': { + const thenEnv = env.clone(); + const elseEnv = env.clone(); + const test = this.eval(e.test, env, f); + this.refine(e.test, thenEnv, f, true); + this.refine(e.test, elseEnv, f, false); + const a = e.then ? this.eval(e.then, thenEnv, f) : test; + const b = this.eval(e.else, elseEnv, f); + return V.join(a, b); + } + case 'bin': { + const l = this.eval(e.left, env, f); + const r = this.eval(e.right, env, f); + // JavaScript's || and && return one of their operands + if (e.op === '??' || e.op === '?:' || (e.valueOps && (e.op === '||' || e.op === '&&'))) return V.join(l, r); + if (e.op === '.') return V.concat([l, r]); + if (['+', '-', '*', '/', '%', '**', '<<', '>>', '&', '|', '^', '<=>'].includes(e.op)) { + if (e.op === '+' && (l.arr || r.arr)) return V.join(l, r); + return { t: false, num: true }; + } + return V.CLEAN; + } + case 'unary': + this.eval(e.expr, env, f); + return e.op === '!' ? V.CLEAN : { t: false, num: true }; + case 'array': { + const arr = new Map(); + let idx = 0; + for (const item of e.items) { + if (!item) continue; + const v = this.eval(item.value, env, f); + if (item.unpack) { + if (v.arr) for (const [, ev] of v.arr) arr.set(String(idx++), ev); + else if (v.t) arr.set('*', arr.has('*') ? V.join(arr.get('*'), v) : v); + continue; + } + let key; + if (item.key) { + const kv = this.eval(item.key, env, f); + key = kv.str !== undefined ? kv.str : '*'; + } else { + key = String(idx++); + } + arr.set(key, key === '*' && arr.has('*') ? V.join(arr.get('*'), v) : v); + } + const all = V.joinAll([...arr.values()]); + return { ...all, arr, str: undefined }; + } + case 'assign': { + let v = this.eval(e.expr, env, f); + if (e.op === '.=') v = V.concat([this.read(e.target, env, f), v]); + else if (e.op === '??=') v = V.join(this.read(e.target, env, f), v); + this.write(e.target, v, env, f, e.line); + return v; + } + case 'closure': { + const fn = e.fn || (e.fnName ? this.findFunction(e.fnName) : null); + if (!fn) return V.CLEAN; + // closures that capture their defining scope (JavaScript) keep a reference to it + return fn.captures ? { t: false, fn, captured: env } : { t: false, fn }; + } + case 'new': + return this.evalNew(e, env, f); + case 'call': + return this.evalCall(e, env, f); + case 'unknown': + return V.weaken(V.joinAll((e.parts || []).map((p) => this.eval(p, env, f)))); + default: + return V.CLEAN; + } + } + + newObjectValue(cls, runConstructor, args = [], env = null, f = null, line = 0) { + const def = this.findClass(cls); + const fields = new Map(); + let obj = { t: false, obj: { cls: def ? def.name : cls, fields } }; + if (def) { + for (const p of this.classChain(def).reverse().flatMap((c) => c.props)) { + fields.set(p.name, p.def && env ? this.eval(p.def, env, f) : V.CLEAN); + } + if (runConstructor) { + const ctor = this.findMethod(def, '__construct') || this.findMethod(def, def.name.toLowerCase()); + if (ctor) { + const res = this.invoke(ctor, args, [], obj, line); + if (res.thisOut && res.thisOut.obj) obj = { ...obj, obj: { cls: obj.obj.cls, fields: res.thisOut.obj.fields } }; + } + } + } + return obj; + } + + classChain(def) { + const chain = []; + let cur = def; + const seen = new Set(); + while (cur && !seen.has(cur.name)) { + chain.push(cur); + seen.add(cur.name); + cur = cur.parent ? this.findClass(cur.parent) : null; + } + return chain; + } + + findClass(name) { + const lc = String(name || '').toLowerCase(); + if (this.p.classes.has(lc)) return this.p.classes.get(lc); + if (this.project) { + const list = this.project.classes.get(lc); + if (list && list.length === 1) return list[0]; + } + return null; + } + + findFunction(lcName) { + if (this.p.functions.has(lcName)) return this.p.functions.get(lcName); + if (this.project) { + const list = this.project.functions.get(lcName); + if (list && list.length === 1) return list[0]; + } + return null; + } + + methodsNamed(lcName) { + const own = this.p.methodsByName.get(lcName) || []; + if (!this.project) return own; + return this.project.methodsByName.get(lcName) || own; + } + + findMethod(def, lcName) { + for (const c of this.classChain(def)) if (c.methods.has(lcName)) return c.methods.get(lcName); + return null; + } + + evalNew(e, env, f) { + const args = (e.args || []).map((a) => this.eval(a, env, f)); + const cls = e.cls; + if (cls && this.findClass(cls)) return this.newObjectValue(cls, true, args, env, f, e.line); + const hit = this.cat.call ? this.cat.call(`new:${String(cls || '').toLowerCase()}`, args, e, this.ctxApi(env, f)) : null; + if (hit) return this.applyCatalogResult(hit, e, args, env, f); + return { t: false, obj: { cls: cls || null, fields: new Map() } }; + } + + /** Resolves an include path (as PHP would) to a file of the project, or null. */ + resolveInclude(candidate, currentFile) { + if (!this.project || typeof candidate !== 'string' || candidate.includes('<') || /^[a-z]+:\/\//i.test(candidate)) return null; + const posix = require('path').posix; + const dirOf = (file) => (file && file.includes('/') ? file.slice(0, file.lastIndexOf('/')) : ''); + const tries = []; + if (candidate.startsWith('/')) tries.push(candidate.replace(/^\/+/, '')); + else { + tries.push(posix.join(dirOf(this.entry), candidate)); + tries.push(posix.join(dirOf(currentFile), candidate)); + tries.push(candidate); + } + for (const t of tries) { + const norm = posix.normalize(t).replace(/^\.\//, ''); + if (!norm.startsWith('..') && this.project.programs.has(norm)) return norm; + } + return null; + } + + /** Runs an included file in the including scope (PHP semantics). */ + executeInclude(target, e, env, f) { + if (!this.project || !target) return; + const depth = f.includeDepth || 0; + if (depth >= 4 || this.includeCount >= 60) return; + const candidates = V.alternatives(target); + if (!candidates) return; + const files = []; + for (const c of candidates) { + const rel = this.resolveInclude(c, f.file || this.entry); + if (!rel || files.includes(rel)) continue; + if (e.once && env.included && env.included.has(rel)) continue; + if ((f.including || []).includes(rel) || rel === (f.file || this.entry)) continue; + files.push(rel); + } + if (files.length === 0) return; + const branches = files.map((rel) => { + const branch = files.length > 1 ? env.clone() : env; + branch.included = new Set([...(branch.included || []), rel]); + const sub = { ...f, file: rel, includeDepth: depth + 1, including: [...(f.including || []), rel] }; + this.includeCount++; + this.execBlock(this.project.programs.get(rel).main, branch, sub); + if (branch.bottom && branch.haltKind === 'top-return') { branch.bottom = false; branch.haltKind = null; } + return branch; + }); + if (files.length > 1) { + const merged = branches[0]; + for (const b of branches.slice(1)) merged.joinFrom(b); + this.replace(env, merged); + env.included = merged.included; + } + } + + ctxApi(env, f) { + const api = { + env, + opts: this.opts, + evalExpr: (x) => this.eval(x, env, f), + readPath: (p) => this.read(p, env, f), + // lets catalogs apply another catalog function (e.g. an array_map callback) + callCatalog: (callee, argVals, line) => (this.cat.call ? this.cat.call(callee, argVals, { callee, args: [], line: line || 0 }, api) : null), + // runs a closure value (callbacks, request handlers) and returns its result + invokeClosure: (cv, argVals, line, thisVal = null) => { + if (!cv || !cv.fn) return V.CLEAN; + const res = this.invoke(cv.fn, argVals || [], [], thisVal, line || cv.fn.line, cv.captured || (cv.fn.captures ? this.mainEnvs.get(cv.fn.file) || null : null)); + return res.ret || V.CLEAN; + }, + findFunction: (name) => this.findFunction(name), + }; + return api; + } + + evalCall(e, env, f) { + const argExprs = e.args || []; + const args = argExprs.map((a) => this.eval(a, env, f)); + const callee = e.callee || ''; + // the receiver of a method call is evaluated once and shared with the catalog + const recvVal = callee.startsWith('m:') && e.recv ? this.eval(e.recv, env, f) : null; + + // user-defined code first + const user = this.resolveUser(e, env, f, recvVal); + if (user) { + const captured = user.fn.captures ? this.mainEnvs.get(user.fn.file) || null : null; + const res = this.invoke(user.fn, args, argExprs, user.thisVal, e.line, captured); + if (user.receiver && res.thisOut && res.thisOut.obj) this.write(user.receiver, res.thisOut, env, f, e.line); + user.fn.params.forEach((p, i) => { + const a = argExprs[i]; + if (p.byRef && a && a.k === 'path' && res.byRefOut && res.byRefOut.has(p.name)) this.write(a, res.byRefOut.get(p.name), env, f, e.line); + }); + return res.ret ? V.step(res.ret, e.line, `returned by ${user.fn.name}()`) : V.CLEAN; + } + + if (callee === 'fn:define' && args[0] && args[0].str !== undefined) { + this.constants.set(args[0].str, args[1] || V.CLEAN); + return V.CLEAN; + } + if (callee === 'fn:dirname' && args[0]) { + const alts = V.alternatives(args[0]); + if (alts && alts.length === 1) return V.constant(alts[0].includes('/') ? alts[0].slice(0, alts[0].lastIndexOf('/')) || '/' : '.'); + } + if (callee === '@include') { + const hit = this.cat.call ? this.cat.call(callee, args, e, this.ctxApi(env, f)) : null; + if (hit) this.applyCatalogResult(hit, e, args, env, f); + this.executeInclude(args[0], e, env, f); + return V.CLEAN; + } + if (callee === '@inline') { + const text = argExprs[0] && argExprs[0].value !== undefined ? String(argExprs[0].value) : ''; + env.out = contexts.htmlScan({ ...env.out }, text); + return V.CLEAN; + } + + const api = this.ctxApi(env, f); + api.recv = recvVal; + const hit = this.cat.call ? this.cat.call(callee, args, e, api) : null; + if (hit) return this.applyCatalogResult(hit, e, args, env, f); + + // unknown function: result depends on arguments, with lower confidence; + // helpers named like escaping functions (defined elsewhere) are probably sanitizers + const joined = V.joinAll(args.map((a) => (a.arr ? V.joinAll([...a.arr.values()]) : a))); + const bare = callee.replace(/^\w+:/, '').split('::').pop(); + const escaperLike = /^(e|h|esc\w*|escape\w*|\w*_?(sanitize|sanitise|clean|purify|encode|filter|safe|xss)\w*|html\w*)$/i.test(bare); + return joined.t ? V.step(V.weaken(joined, escaperLike ? 2 : 1), e.line, `through ${bare}()`) : V.CLEAN; + } + + applyCatalogResult(hit, e, args, env, f) { + for (const sink of hit.sinks || []) this.checkSink(sink, e, args, env, f); + for (const [idx, v] of hit.byRef || []) { + const a = e.args[idx]; + if (a && (a.k === 'path' || a.k === 'list')) this.write(a, v, env, f, e.line); + } + // methods that change their receiver (e.g. JavaScript's array.push) + if (hit.recvUpdate && e.recv && e.recv.k === 'path') this.write(e.recv, hit.recvUpdate, env, f, e.line); + return hit.value || V.CLEAN; + } + + resolveUser(e, env, f, recvVal = null) { + const callee = e.callee || ''; + if (callee.startsWith('fn:')) { + const fn = this.findFunction(callee.slice(3).replace(/^\\/, '').split('\\').pop()); + return fn ? { fn, thisVal: null } : null; + } + if (callee.startsWith('m:') && e.recv) { + const name = callee.slice(2); + const recv = recvVal || this.eval(e.recv, env, f); + let fn = null; + if (recv.obj && recv.obj.cls) { + const def = this.findClass(recv.obj.cls); + if (def) fn = this.findMethod(def, name); + } + if (!fn) { + const candidates = this.methodsNamed(name); + if (candidates.length === 1 && !(this.cat.isKnownMethod && this.cat.isKnownMethod(name))) fn = candidates[0]; + } + if (!fn) return null; + const thisVal = recv.obj ? recv : this.newObjectValue(fn.cls || '', false); + return { fn, thisVal, receiver: e.recv.k === 'path' ? e.recv : null }; + } + if (callee.startsWith('sm:')) { + const [cls, name] = callee.slice(3).split('::'); + let def = null; + if (['self', 'static'].includes(cls) && f.fn && f.fn.cls) def = this.findClass(f.fn.cls); + else if (cls === 'parent' && f.fn && f.fn.cls) { + const own = this.findClass(f.fn.cls); + def = own && own.parent ? this.findClass(own.parent) : null; + } else def = this.findClass(cls); + const fn = def ? this.findMethod(def, name) : null; + if (!fn) return null; + const thisVal = env.vars.get('this') || null; + return { fn, thisVal }; + } + return null; + } + + /** + * @param {Env|null} captured scope a closure was created in (JavaScript); its variables are + * visible inside the function, parameters shadow them + */ + invoke(fn, args, argExprs, thisVal, line, captured = null) { + this.analyzed.add(fn); + const fallback = () => { + const joined = V.joinAll(args); + return { ret: joined.t ? V.weaken(joined) : V.CLEAN, thisOut: thisVal, byRefOut: new Map() }; + }; + if (this.depth >= MAX_DEPTH || this.exhausted) return fallback(); + const key = `${fn.id}#${signature(args)}#${signature([thisVal])}${captured ? `#${captureSignature(captured)}` : ''}`; + if (this.memo.has(key)) { + const cached = this.memo.get(key); + // findings produced inside this function are reachable from the current entry point too + for (const k of cached.hitKeys || []) { const h = this.hits.get(k); if (h) h.entries.add(this.entry); } + return cached; + } + this.memo.set(key, fallback()); // recursion guard + const logStart = this.hitLog.length; + const env = new Env(); + if (captured) for (const [k, v] of captured.vars) env.vars.set(k, v); + const prefix = this.style.varPrefix !== undefined ? this.style.varPrefix : '$'; + fn.params.forEach((p, i) => { + let v = args[i]; + if (p.variadic) v = V.joinAll(args.slice(i)); + if (v === undefined) v = p.def ? this.eval(p.def, env, { fn, file: fn.file }) : V.CLEAN; + env.vars.set(p.name, v && v.t ? V.step(v, line, `passed to ${fn.name}() as ${prefix}${p.name}`) : v); + }); + if (thisVal) env.vars.set('this', thisVal); + const f = { fn, file: fn.file || this.p.file, ret: null, thisOut: null, byRefParams: fn.params.filter((p) => p.byRef).map((p) => p.name), byRefOut: new Map() }; + this.depth++; + try { + this.execBlock(fn.body, env, f); + } finally { + this.depth--; + } + if (!env.bottom) this.recordExit(env, f); + const result = { ret: f.ret || V.CLEAN, thisOut: f.thisOut || thisVal, byRefOut: f.byRefOut, hitKeys: this.hitLog.slice(logStart) }; + this.memo.set(key, result); + return result; + } + + /* ---------------------------------------------------------------- sinks */ + + checkSink(sink, e, args, env, f = {}) { + let value; + if (sink.value) value = sink.value; + else if (sink.arg === 'all') value = V.concat(args); + else value = args[sink.arg]; + if (!value) return; + let unsafe; + if (sink.check === 'html') { + // whole-response sinks (e.g. res.send) start a new HTML document + const res = contexts.html(value, sink.freshHtml ? contexts.initialHtmlState() : env.out); + if (!sink.freshHtml) env.out = res.state; + unsafe = res.unsafe; + } else if (!value.t) { + return; + } else { + const fn = contexts[sink.check] || contexts.any; + unsafe = sink.check === 'urlControl' ? contexts.urlControl(value, sink.prefixRe) : fn(value); + } + if (!unsafe || !unsafe.length) return; + for (const u of unsafe) { + const v = u.v; + if (!v.origins || !v.origins.some((o) => o === 'src' || o === 'src2')) continue; + const conf = Math.min(2, (v.c || 0) + (v.g ? 2 : 0) + (sink.confPenalty || 0)); + const file = f.file || this.p.file; + const key = `${file}|${sink.rule}|${e.line}|${e.col || 0}`; + const prev = this.hits.get(key); + this.hitLog.push(key); + if (prev) prev.entries.add(this.entry); + if (prev && prev.conf <= conf && prev.trace.length <= (v.trace || []).length) continue; + this.hits.set(key, { + file, + entries: prev ? prev.entries : new Set([this.entry]), + rule: sink.rule, + line: e.line, + col: e.col || null, + sink: sink.name || e.callee, + context: u.context, + conf, + trace: (v.trace || []).slice(), + secondOrder: Boolean(v.origins && v.origins.includes('src2') && !v.origins.includes('src')), + }); + } + } +} + +module.exports = { Interpreter, Env }; diff --git a/core/taint/project.js b/core/taint/project.js new file mode 100644 index 0000000..5fe9e6c --- /dev/null +++ b/core/taint/project.js @@ -0,0 +1,79 @@ +'use strict'; +/* + * Project-wide taint analysis shared by the language plugins. + * + * Every file is parsed and lowered once. Each file then runs as an entry point with + * functions, classes and methods resolved across the project; functions that no entry + * point called (controllers, request handlers, library code) are analyzed afterwards. + */ +const { Interpreter } = require('./interpreter'); + +function push(map, key, value) { + if (!map.has(key)) map.set(key, []); + map.get(key).push(value); +} + +/** + * @param {Array<{rel:string, text:string}>} files + * @param {{parse:(text:string, rel:string)=>{ast, status, error}, lower:(ast, rel:string)=>object, catalog:object}} language + * @param {object} options interpreter options (secondOrder, budget, ...) + * @param {(rel:string, ast:object|null, parsed:{status,error})=>void} [onParsed] called once per file + * @returns {{hits:Array, status:Map, exhausted:number}} + */ +function analyzeProject(files, language, options = {}, onParsed) { + const { catalog } = language; + const status = new Map(); + const project = { programs: new Map(), functions: new Map(), classes: new Map(), methodsByName: new Map() }; + + for (const { rel, text } of files) { + const parsed = language.parse(text, rel); + let program = null; + let error = parsed.error; + if (parsed.ast) { + try { + program = language.lower(parsed.ast, rel); + } catch (err) { + error = `lowering: ${err.message}`; + } + } + // "skipped" files (minified or generated code) are not parse failures + const st = program ? parsed.status : (parsed.status === 'skipped' ? 'skipped' : 'failed'); + status.set(rel, { status: st, error }); + if (onParsed) onParsed(rel, parsed.ast || null, { status: st, error }); + if (!program) continue; + project.programs.set(rel, program); + for (const [name, fn] of program.functions) push(project.functions, name, fn); + for (const [name, cls] of program.classes) push(project.classes, name, cls); + for (const [name, list] of program.methodsByName) for (const fn of list) push(project.methodsByName, name, fn); + } + + const shared = { hits: new Map(), memo: new Map(), analyzed: new Set(), mainEnvs: new Map() }; + let exhausted = 0; + for (const [rel, program] of project.programs) { + const interpreter = new Interpreter(program, catalog, { ...options, project, shared }); + try { + if (interpreter.run({ standalone: false }).exhausted) exhausted++; + } catch (err) { + status.get(rel).error = `analysis: ${err.message}`; + } + } + + // functions and methods that no entry point called (libraries, controllers, hooks, handlers) + const all = [...project.programs.values()].flatMap((p) => p.allFunctions); + const empty = { file: '', main: [], functions: new Map(), classes: new Map(), methodsByName: new Map(), allFunctions: all }; + // one shared budget keeps memory bounded on very large projects; running out is reported + const remaining = new Interpreter(empty, catalog, { ...options, project, shared }); + try { + remaining.analyzeRemaining(all); + } catch (_) { /* best effort */ } + + const hits = [...shared.hits.values()].map((h) => ({ + ...h, + entries: [...h.entries].filter((e) => e && e !== h.file).sort(), + conf: status.get(h.file) && status.get(h.file).status === 'recovered' ? 2 : h.conf, + })); + const uncovered = remaining.exhausted ? all.filter((fn) => !shared.analyzed.has(fn)).length : 0; + return { hits, status, exhausted, uncovered }; +} + +module.exports = { analyzeProject }; diff --git a/core/taint/value.js b/core/taint/value.js new file mode 100644 index 0000000..6f4ffad --- /dev/null +++ b/core/taint/value.js @@ -0,0 +1,255 @@ +'use strict'; +/* + * Abstract values for taint analysis (language independent). + * + * A value is a plain object: + * t tainted (attacker influenced) + * c confidence of the taint: 0 high, 1 medium, 2 low + * g guarded: passed a validation check that may or may not be sufficient + * allowed string of characters the value can contain, or null (anything) + * enc encodings applied: { html, htmlQuotes, sql, shell, shellCmd, ldap, url } + * trace [{line, note}] from source to here (bounded) + * origins Set-like array of origin ids ('src' or 'p0', 'p1', ... for parameters) + * str known constant string (untainted values only) + * segs composite string: [{text} | {v: value}] (keeps sink context information) + * arr Map key -> value for arrays ('*' = unknown keys) + * obj {cls, fields: Map} for objects + */ + +const MAX_TRACE = 8; +const MAX_SEGS = 48; +const MAX_STR = 4000; + +const CLEAN = Object.freeze({ t: false }); + +function constant(str) { + if (str === undefined || str === null) return CLEAN; + const s = String(str); + return { t: false, str: s.length > MAX_STR ? s.slice(0, MAX_STR) : s }; +} + +function source(origin, note, line, conf = 0) { + return { t: true, c: conf, g: false, allowed: null, enc: {}, trace: [{ line, note }], origins: [origin] }; +} + +function isTainted(v) { + return Boolean(v && v.t); +} + +function unionChars(a, b) { + if (a === null || a === undefined || b === null || b === undefined) return null; + let out = a; + for (const ch of b) if (!out.includes(ch)) out += ch; + return out; +} + +function intersectEnc(a = {}, b = {}) { + const out = {}; + for (const k of Object.keys(a)) if (a[k] && b[k]) out[k] = a[k] === b[k] ? a[k] : true; + return out; +} + +function mergeOrigins(a = [], b = []) { + const out = a.slice(); + for (const o of b) if (!out.includes(o)) out.push(o); + return out; +} + +function shorterTrace(a, b) { + if (!a) return b; + if (!b) return a; + return b.length < a.length ? b : a; +} + +/** Least upper bound of two values (used at control-flow merges and for "either" results). */ +function join(a, b) { + if (!a) return b || CLEAN; + if (!b) return a; + if (a === b) return a; + let out; + if (a.t && b.t) { + out = { + t: true, + c: Math.min(a.c, b.c), + g: Boolean(a.g && b.g), + allowed: unionChars(a.allowed, b.allowed), + enc: intersectEnc(a.enc, b.enc), + trace: shorterTrace(a.trace, b.trace), + origins: mergeOrigins(a.origins, b.origins), + }; + } else if (a.t || b.t) { + const t = a.t ? a : b; + out = { ...t }; + delete out.str; + delete out.segs; + } else { + out = { t: false }; + if (a.str !== undefined && a.str === b.str) out.str = a.str; + else { + const set = unionAlternatives(alternatives(a), alternatives(b)); + if (set) out.strs = set; + } + } + if (a.arr || b.arr) out.arr = joinMaps(a.arr, b.arr); + if (a.obj || b.obj) { + const cls = a.obj && b.obj ? (a.obj.cls === b.obj.cls ? a.obj.cls : null) : (a.obj || b.obj).cls; + out.obj = { cls, fields: joinMaps(a.obj && a.obj.fields, b.obj && b.obj.fields) }; + } + if (a.num && b.num) out.num = true; + return out; +} + +const MAX_ALTERNATIVES = 8; + +/** Possible constant string values of an untainted value, or null when unknown. */ +function alternatives(v) { + if (!v || v.t) return null; + if (v.str !== undefined) return [v.str]; + if (v.strs) return v.strs; + if (v.num && v.str === undefined) return null; + return null; +} + +function unionAlternatives(a, b) { + if (!a || !b) return null; + const set = [...new Set([...a, ...b])]; + return set.length <= MAX_ALTERNATIVES ? set : null; +} + +function joinMaps(a, b) { + const out = new Map(a || []); + for (const [k, v] of b || []) out.set(k, out.has(k) ? join(out.get(k), v) : v); + return out; +} + +function joinAll(values) { + return values.reduce((acc, v) => join(acc, v), null) || CLEAN; +} + +/** Adds a trace step (returns a new value). */ +function step(v, line, note) { + if (!v || !v.t) return v; + const trace = (v.trace || []).concat([{ line, note }]); + return { ...v, trace: trace.length > MAX_TRACE ? trace.slice(0, 2).concat(trace.slice(-(MAX_TRACE - 2))) : trace }; +} + +/** Lowers confidence by n steps (max low). */ +function weaken(v, n = 1) { + if (!v || !v.t) return v; + return { ...v, c: Math.min(2, (v.c || 0) + n) }; +} + +/** Concatenation preserving segment structure for context-sensitive sinks. */ +function concat(values) { + const segs = []; + let anyTaint = false; + let constText = ''; + let allConst = true; + for (const v of values) { + if (!v) continue; + if (v.t) { + anyTaint = true; + allConst = false; + if (v.segs) segs.push(...v.segs); + else segs.push({ v }); + } else if (v.segs) { + // untainted composite cannot exist; treat as text + allConst = false; + } else if (v.str !== undefined) { + segs.push({ text: v.str }); + constText += v.str; + } else { + allConst = false; + segs.push({ text: '' }); // unknown untainted text (e.g. a number or unknown clean value) + } + } + if (!anyTaint) { + if (allConst) return constant(constText); + // several possible constant strings (e.g. a file name chosen in a switch) + let combos = ['']; + for (const v of values) { + const alts = alternatives(v); + if (!alts) return CLEAN; + const next = []; + for (const c of combos) for (const a of alts) next.push(c + a); + if (next.length > MAX_ALTERNATIVES) return CLEAN; + combos = next; + } + return combos.length === 1 ? constant(combos[0]) : { t: false, strs: combos }; + } + const tainted = segs.filter((s) => s.v).map((s) => s.v); + const base = joinAll(tainted); + const merged = mergeTextSegs(segs); + const out = { ...base }; + delete out.str; + out.segs = merged.length > MAX_SEGS ? null : merged; + if (!out.segs) delete out.segs; + return out; +} + +function mergeTextSegs(segs) { + const out = []; + for (const s of segs) { + const last = out[out.length - 1]; + if (s.text !== undefined && last && last.text !== undefined) last.text += s.text; + else out.push(s.text !== undefined ? { text: s.text } : s); + } + return out; +} + +/** The segments of a value (atomic tainted values form a single segment). */ +function segmentsOf(v) { + if (!v || !v.t) return v && v.str !== undefined ? [{ text: v.str }] : []; + return v.segs && v.segs.length ? v.segs : [{ v }]; +} + +/** Applies a sanitizer effect: {clean, allowed, enc:{...}} */ +function sanitize(v, effect, line, note) { + if (!v || !v.t) return v && v.str !== undefined && effect.keepConst ? v : (v && v.str !== undefined ? constant(v.str) : CLEAN); + if (effect.clean) return { t: false, num: Boolean(effect.num) }; + const out = { ...v }; + delete out.segs; + delete out.str; + if (effect.allowed !== undefined) { + out.allowed = out.allowed === null || out.allowed === undefined ? effect.allowed : intersectChars(out.allowed, effect.allowed); + } + if (effect.removeChars) { + if (out.allowed) out.allowed = [...out.allowed].filter((ch) => !effect.removeChars.includes(ch)).join(''); + else out.removed = (out.removed || '') + effect.removeChars; + } + if (effect.enc) out.enc = { ...(out.enc || {}), ...effect.enc }; + if (effect.dropEnc) { + out.enc = { ...(out.enc || {}) }; + for (const k of effect.dropEnc) delete out.enc[k]; + } + return step(out, line, note); +} + +function intersectChars(a, b) { + return [...a].filter((ch) => b.includes(ch)).join(''); +} + +/** True if the value can contain none of the given characters. */ +function excludes(v, chars) { + if (v.allowed !== null && v.allowed !== undefined) { + for (const ch of chars) if (v.allowed.includes(ch)) return false; + return true; + } + if (v.removed) { + for (const ch of chars) if (!v.removed.includes(ch)) return false; + return true; + } + return false; +} + +/** True if every possible character is in the given set. */ +function within(v, chars) { + if (v.allowed === null || v.allowed === undefined) return false; + for (const ch of v.allowed) if (!chars.includes(ch)) return false; + return true; +} + +module.exports = { + CLEAN, constant, source, isTainted, join, joinAll, joinMaps, step, weaken, concat, segmentsOf, + sanitize, excludes, within, unionChars, MAX_TRACE, alternatives, +}; diff --git a/core/walker.js b/core/walker.js new file mode 100644 index 0000000..632dcb2 --- /dev/null +++ b/core/walker.js @@ -0,0 +1,128 @@ +'use strict'; +/* + * Project file discovery: one walk per scan, shared by every check. + * + * - skips version-control and IDE folders, and dependency folders (vendor/, + * node_modules/, bower_components/) unless includeVendor is set + * - skips ASST's own folder when it sits inside the scanned tree + * - follows directory symlinks at most once (no cycles) + * - honours user exclude globs (config EXCLUDE_PATHS, --exclude, .asstignore) + */ +const fs = require('fs'); +const path = require('path'); + +const VCS_DIRS = new Set(['.git', '.svn', '.hg', '.bzr', '.idea', '.vscode', '.asst-cache']); +const DEPENDENCY_DIRS = new Set(['vendor', 'node_modules', 'bower_components']); + +function toPosix(p) { + return p.split(path.sep).join('/'); +} + +/** Converts a glob (supports **, *, ?) to a RegExp over posix relative paths. */ +function globToRegExp(glob) { + let g = toPosix(String(glob).trim()); + const rooted = g.startsWith('/'); + if (rooted) g = g.slice(1); + if (g.endsWith('/')) g = g.slice(0, -1); + const anchored = rooted || (g.includes('/') && !g.startsWith('**/')); + let re = ''; + for (let i = 0; i < g.length; i++) { + const c = g[i]; + if (c === '*') { + if (g[i + 1] === '*') { + re += '.*'; + i++; + if (g[i + 1] === '/') i++; + } else { + re += '[^/]*'; + } + } else if (c === '?') { + re += '[^/]'; + } else { + re += c.replace(/[.+^${}()|[\]\\]/g, '\\$&'); + } + } + const prefix = anchored ? '^' : '(^|/)'; + return new RegExp(`${prefix}${re}(/.*)?$`, process.platform === 'win32' ? 'i' : ''); +} + +function normalizeAbs(p) { + const r = path.resolve(p); + return process.platform === 'win32' ? r.toLowerCase() : r; +} + +/** + * @param {string} root absolute folder to scan + * @param {{exclude?:string[], includeVendor?:boolean, skipPaths?:string[]}} opts + * @returns {{root:string, files:Array<{rel,abs,name,ext,size}>, skipped:Array<{rel,reason}>}} + */ +function walkProject(root, opts = {}) { + const exclude = (opts.exclude || []).filter(Boolean).map(globToRegExp); + const skipPaths = new Set((opts.skipPaths || []).map(normalizeAbs)); + const includeVendor = Boolean(opts.includeVendor); + const files = []; + const skipped = []; + const visited = new Set(); + try { visited.add(normalizeAbs(fs.realpathSync(root))); } catch (_) { /* reported by caller */ } + + const isExcluded = (rel) => exclude.some((re) => re.test(rel)); + const stack = ['']; + while (stack.length) { + const relDir = stack.pop(); + const absDir = relDir ? path.join(root, relDir) : root; + let entries; + try { + entries = fs.readdirSync(absDir, { withFileTypes: true }); + } catch (err) { + skipped.push({ rel: relDir || '.', reason: `unreadable (${err.code || err.message})` }); + continue; + } + for (const entry of entries) { + const rel = relDir ? `${relDir}/${entry.name}` : entry.name; + const abs = path.join(absDir, entry.name); + let isDir = entry.isDirectory(); + let isFile = entry.isFile(); + if (entry.isSymbolicLink()) { + try { + const st = fs.statSync(abs); + isDir = st.isDirectory(); + isFile = st.isFile(); + } catch (_) { + skipped.push({ rel, reason: 'broken symlink' }); + continue; + } + } + if (isDir) { + if (skipPaths.has(normalizeAbs(abs))) { skipped.push({ rel, reason: 'asst' }); continue; } + if (VCS_DIRS.has(entry.name)) { skipped.push({ rel, reason: 'vcs' }); continue; } + if (!includeVendor && DEPENDENCY_DIRS.has(entry.name)) { skipped.push({ rel, reason: 'dependencies' }); continue; } + if (isExcluded(rel)) { skipped.push({ rel, reason: 'excluded' }); continue; } + let real; + try { real = normalizeAbs(fs.realpathSync(abs)); } catch (_) { continue; } + if (visited.has(real)) { skipped.push({ rel, reason: 'symlink cycle' }); continue; } + visited.add(real); + stack.push(rel); + } else if (isFile) { + if (isExcluded(rel)) continue; + let size = 0; + try { size = fs.statSync(abs).size; } catch (_) { continue; } + const dot = entry.name.lastIndexOf('.'); + files.push({ rel, abs, name: entry.name, ext: dot > 0 ? entry.name.slice(dot + 1).toLowerCase() : '', size }); + } + } + } + files.sort((a, b) => (a.rel < b.rel ? -1 : a.rel > b.rel ? 1 : 0)); + skipped.sort((a, b) => (a.rel < b.rel ? -1 : 1)); + return { root, files, skipped }; +} + +/** Reads an .asstignore file (one glob per line, # comments). */ +function readIgnoreFile(file) { + try { + return fs.readFileSync(file, 'utf8').split(/\r?\n/).map((l) => l.trim()).filter((l) => l && !l.startsWith('#')); + } catch (_) { + return []; + } +} + +module.exports = { walkProject, globToRegExp, readIgnoreFile, toPosix, VCS_DIRS, DEPENDENCY_DIRS }; diff --git a/data/eol.json b/data/eol.json new file mode 100644 index 0000000..9c5ea47 --- /dev/null +++ b/data/eol.json @@ -0,0 +1,1788 @@ +{ + "source": "https://endoflife.date (php, mysql, mariadb, nodejs, laravel, symfony, drupal, wordpress, jquery, bootstrap, angularjs, vue)", + "asOf": "2026-11-13", + "note": "Refreshed with --online; security support ends at \"eol\", bug-fix support at \"support\".", + "products": { + "php": [ + { + "cycle": "8.5", + "eol": "2029-12-31", + "support": "2027-12-31", + "lts": false, + "latest": "8.5.12" + }, + { + "cycle": "8.4", + "eol": "2028-12-31", + "support": "2026-12-31", + "lts": false, + "latest": "8.4.27" + }, + { + "cycle": "8.3", + "eol": "2027-12-31", + "support": "2025-12-31", + "lts": false, + "latest": "8.3.36" + }, + { + "cycle": "8.2", + "eol": "2026-12-31", + "support": "2024-12-31", + "lts": false, + "latest": "8.2.35" + }, + { + "cycle": "8.1", + "eol": "2025-12-31", + "support": "2023-11-25", + "lts": false, + "latest": "8.1.34" + }, + { + "cycle": "8.0", + "eol": "2023-11-26", + "support": "2022-11-26", + "lts": false, + "latest": "8.0.30" + }, + { + "cycle": "7.4", + "eol": "2022-11-28", + "support": "2021-11-28", + "lts": false, + "latest": "7.4.33" + }, + { + "cycle": "7.3", + "eol": "2021-12-06", + "support": "2020-12-06", + "lts": false, + "latest": "7.3.33" + }, + { + "cycle": "7.2", + "eol": "2020-11-30", + "support": "2019-11-30", + "lts": false, + "latest": "7.2.34" + }, + { + "cycle": "7.1", + "eol": "2019-12-01", + "support": "2018-12-01", + "lts": false, + "latest": "7.1.33" + }, + { + "cycle": "7.0", + "eol": "2019-01-10", + "support": "2018-01-04", + "lts": false, + "latest": "7.0.33" + }, + { + "cycle": "5.6", + "eol": "2018-12-31", + "support": "2017-01-19", + "lts": false, + "latest": "5.6.40" + }, + { + "cycle": "5.5", + "eol": "2016-07-21", + "support": "2015-07-10", + "lts": false, + "latest": "5.5.38" + }, + { + "cycle": "5.4", + "eol": "2015-09-14", + "support": "2014-09-14", + "lts": false, + "latest": "5.4.45" + }, + { + "cycle": "5.3", + "eol": "2014-08-14", + "support": "2011-06-30", + "lts": false, + "latest": "5.3.29" + }, + { + "cycle": "5.2", + "eol": "2011-01-06", + "support": "2008-11-02", + "lts": false, + "latest": "5.2.17" + }, + { + "cycle": "5.1", + "eol": "2006-08-24", + "support": "2006-08-24", + "lts": false, + "latest": "5.1.6" + }, + { + "cycle": "4.4", + "eol": "2008-08-07", + "support": "2007-12-31", + "lts": false, + "latest": "4.4.9" + }, + { + "cycle": "5.0", + "eol": "2005-09-05", + "support": "2005-09-05", + "lts": false, + "latest": "5.0.5" + }, + { + "cycle": "4.3", + "eol": "2005-03-31", + "support": "2005-03-31", + "lts": false, + "latest": "4.3.11" + }, + { + "cycle": "4.2", + "eol": "2002-09-06", + "support": "2002-09-06", + "lts": false, + "latest": "4.2.3" + }, + { + "cycle": "4.1", + "eol": "2002-03-12", + "support": "2002-03-12", + "lts": false, + "latest": "4.1.2" + }, + { + "cycle": "4.0", + "eol": "2001-06-23", + "support": "2001-06-23", + "lts": false, + "latest": "4.0.6" + } + ], + "mysql": [ + { + "cycle": "26.10", + "eol": false, + "support": true, + "lts": false, + "latest": "26.10.0" + }, + { + "cycle": "26.7", + "eol": "2026-10-20", + "support": "2026-10-20", + "lts": false, + "latest": "26.7.1" + }, + { + "cycle": "9.7", + "eol": "2034-04-30", + "support": "2031-04-30", + "lts": true, + "latest": "9.7.4" + }, + { + "cycle": "9.6", + "eol": "2026-04-21", + "support": "2026-04-21", + "lts": false, + "latest": "9.6.1" + }, + { + "cycle": "9.5", + "eol": "2026-01-20", + "support": "2026-01-20", + "lts": false, + "latest": "9.5.2" + }, + { + "cycle": "9.4", + "eol": "2025-10-21", + "support": "2025-10-21", + "lts": false, + "latest": "9.4.2" + }, + { + "cycle": "9.3", + "eol": "2025-07-22", + "support": "2025-07-22", + "lts": false, + "latest": "9.3.2" + }, + { + "cycle": "9.2", + "eol": "2025-04-15", + "support": "2025-04-15", + "lts": false, + "latest": "9.2.2" + }, + { + "cycle": "9.1", + "eol": "2025-01-21", + "support": "2025-01-21", + "lts": false, + "latest": "9.1.2" + }, + { + "cycle": "9.0", + "eol": "2024-10-15", + "support": "2024-10-15", + "lts": false, + "latest": "9.0.1" + }, + { + "cycle": "8.4", + "eol": "2032-04-30", + "support": "2029-04-30", + "lts": true, + "latest": "8.4.13" + }, + { + "cycle": "8.3", + "eol": "2024-04-30", + "support": "2024-04-30", + "lts": false, + "latest": "8.3.0" + }, + { + "cycle": "8.2", + "eol": "2024-01-16", + "support": "2024-01-16", + "lts": false, + "latest": "8.2.0" + }, + { + "cycle": "8.1", + "eol": "2023-10-25", + "support": "2023-10-25", + "lts": false, + "latest": "8.1.0" + }, + { + "cycle": "8.0", + "eol": "2026-04-30", + "support": "2025-04-30", + "lts": "2023-07-18", + "latest": "8.0.46" + }, + { + "cycle": "5.7", + "eol": "2023-10-31", + "support": "2020-10-31", + "lts": false, + "latest": "5.7.44" + }, + { + "cycle": "5.6", + "eol": "2021-02-28", + "support": "2018-02-28", + "lts": false, + "latest": "5.6.51" + }, + { + "cycle": "5.5", + "eol": "2018-12-31", + "support": "2015-12-31", + "lts": false, + "latest": "5.5.63" + }, + { + "cycle": "5.1", + "eol": "2013-12-31", + "support": "2013-12-31", + "lts": false, + "latest": "5.1.73" + }, + { + "cycle": "5.0", + "eol": "2011-12-31", + "support": "2011-12-31", + "lts": false, + "latest": "5.0.96" + }, + { + "cycle": "4.1", + "eol": "2009-12-31", + "support": "2006-12-31", + "lts": false, + "latest": "4.1.24" + }, + { + "cycle": "4.0", + "eol": "2008-09-30", + "support": "2006-09-30", + "lts": false, + "latest": "4.0.30" + }, + { + "cycle": "3.23", + "eol": "2006-12-31", + "support": "2006-07-31", + "lts": false, + "latest": "3.23.58" + } + ], + "mariadb": [ + { + "cycle": "13.0", + "eol": "2026-12-31", + "support": null, + "lts": false, + "latest": "13.0.2" + }, + { + "cycle": "12.3", + "eol": "2029-06-12", + "support": null, + "lts": true, + "latest": "12.3.3" + }, + { + "cycle": "12.2", + "eol": "2026-05-28", + "support": null, + "lts": false, + "latest": "12.2.2" + }, + { + "cycle": "12.1", + "eol": "2026-02-13", + "support": null, + "lts": false, + "latest": "12.1.2" + }, + { + "cycle": "12.0", + "eol": "2025-11-18", + "support": null, + "lts": false, + "latest": "12.0.2" + }, + { + "cycle": "11.8", + "eol": "2028-06-04", + "support": null, + "lts": true, + "latest": "11.8.9" + }, + { + "cycle": "11.7", + "eol": "2025-05-12", + "support": null, + "lts": false, + "latest": "11.7.2" + }, + { + "cycle": "11.6", + "eol": "2025-02-13", + "support": null, + "lts": false, + "latest": "11.6.2" + }, + { + "cycle": "11.5", + "eol": "2024-11-21", + "support": null, + "lts": false, + "latest": "11.5.2" + }, + { + "cycle": "11.4", + "eol": "2029-05-29", + "support": null, + "lts": true, + "latest": "11.4.13" + }, + { + "cycle": "11.3", + "eol": "2024-05-29", + "support": null, + "lts": false, + "latest": "11.3.2" + }, + { + "cycle": "11.2", + "eol": "2024-11-21", + "support": null, + "lts": false, + "latest": "11.2.6" + }, + { + "cycle": "11.1", + "eol": "2024-08-21", + "support": null, + "lts": false, + "latest": "11.1.6" + }, + { + "cycle": "11.0", + "eol": "2024-06-06", + "support": null, + "lts": false, + "latest": "11.0.6" + }, + { + "cycle": "10.11", + "eol": "2028-02-16", + "support": null, + "lts": true, + "latest": "10.11.19" + }, + { + "cycle": "10.10", + "eol": "2023-11-17", + "support": null, + "lts": false, + "latest": "10.10.7" + }, + { + "cycle": "10.9", + "eol": "2023-08-22", + "support": null, + "lts": false, + "latest": "10.9.8" + }, + { + "cycle": "10.8", + "eol": "2023-05-20", + "support": null, + "lts": false, + "latest": "10.8.8" + }, + { + "cycle": "10.7", + "eol": "2023-02-09", + "support": null, + "lts": false, + "latest": "10.7.8" + }, + { + "cycle": "10.6", + "eol": "2026-07-06", + "support": null, + "lts": true, + "latest": "10.6.28" + }, + { + "cycle": "10.5", + "eol": "2025-06-24", + "support": null, + "lts": true, + "latest": "10.5.29" + }, + { + "cycle": "10.4", + "eol": "2024-06-18", + "support": null, + "lts": true, + "latest": "10.4.34" + }, + { + "cycle": "10.3", + "eol": "2023-05-25", + "support": null, + "lts": false, + "latest": "10.3.39" + }, + { + "cycle": "10.2", + "eol": "2022-05-23", + "support": null, + "lts": false, + "latest": "10.2.44" + }, + { + "cycle": "10.1", + "eol": "2020-10-17", + "support": null, + "lts": false, + "latest": "10.1.48" + }, + { + "cycle": "10.0", + "eol": "2019-03-31", + "support": null, + "lts": false, + "latest": "10.0.38" + }, + { + "cycle": "5.5", + "eol": "2020-04-11", + "support": null, + "lts": true, + "latest": "5.5.68" + }, + { + "cycle": "5.3", + "eol": "2017-03-01", + "support": null, + "lts": false, + "latest": "5.3.12" + }, + { + "cycle": "5.2", + "eol": "2015-11-10", + "support": null, + "lts": false, + "latest": "5.2.14" + }, + { + "cycle": "5.1", + "eol": "2015-02-01", + "support": null, + "lts": false, + "latest": "5.1.67" + } + ], + "nodejs": [ + { + "cycle": "26", + "eol": "2029-04-30", + "support": "2027-10-27", + "lts": "2026-10-28", + "latest": "26.13.1" + }, + { + "cycle": "25", + "eol": "2026-06-01", + "support": "2026-04-01", + "lts": false, + "latest": "25.9.0" + }, + { + "cycle": "24", + "eol": "2028-04-30", + "support": "2026-10-20", + "lts": "2025-10-28", + "latest": "24.22.3" + }, + { + "cycle": "23", + "eol": "2025-06-01", + "support": "2025-04-01", + "lts": false, + "latest": "23.11.1" + }, + { + "cycle": "22", + "eol": "2027-04-30", + "support": "2025-10-21", + "lts": "2024-10-29", + "latest": "22.23.5" + }, + { + "cycle": "21", + "eol": "2024-06-01", + "support": "2024-04-01", + "lts": false, + "latest": "21.7.3" + }, + { + "cycle": "20", + "eol": "2026-04-30", + "support": "2024-10-22", + "lts": "2023-10-24", + "latest": "20.20.2" + }, + { + "cycle": "19", + "eol": "2023-06-01", + "support": "2023-04-01", + "lts": false, + "latest": "19.9.0" + }, + { + "cycle": "18", + "eol": "2025-04-30", + "support": "2023-10-18", + "lts": "2022-10-25", + "latest": "18.20.8" + }, + { + "cycle": "17", + "eol": "2022-06-01", + "support": "2022-04-01", + "lts": false, + "latest": "17.9.1" + }, + { + "cycle": "16", + "eol": "2023-09-11", + "support": "2022-10-18", + "lts": "2021-10-26", + "latest": "16.20.2" + }, + { + "cycle": "15", + "eol": "2021-06-01", + "support": "2021-04-01", + "lts": false, + "latest": "15.14.0" + }, + { + "cycle": "14", + "eol": "2023-04-30", + "support": "2021-10-19", + "lts": "2020-10-27", + "latest": "14.21.3" + }, + { + "cycle": "13", + "eol": "2020-06-01", + "support": "2020-04-01", + "lts": false, + "latest": "13.14.0" + }, + { + "cycle": "12", + "eol": "2022-04-30", + "support": "2020-10-20", + "lts": "2019-10-21", + "latest": "12.22.12" + }, + { + "cycle": "11", + "eol": "2019-06-30", + "support": "2019-04-01", + "lts": false, + "latest": "11.15.0" + }, + { + "cycle": "10", + "eol": "2021-04-30", + "support": "2020-05-19", + "lts": "2018-10-30", + "latest": "10.24.1" + }, + { + "cycle": "9", + "eol": "2018-06-30", + "support": "2018-06-30", + "lts": false, + "latest": "9.11.2" + }, + { + "cycle": "8", + "eol": "2019-12-31", + "support": "2019-01-01", + "lts": "2017-10-31", + "latest": "8.17.0" + }, + { + "cycle": "7", + "eol": "2017-06-30", + "support": "2017-06-30", + "lts": false, + "latest": "7.10.1" + }, + { + "cycle": "6", + "eol": "2019-04-30", + "support": "2018-04-30", + "lts": "2016-10-18", + "latest": "6.17.1" + }, + { + "cycle": "5", + "eol": "2016-06-30", + "support": "2016-06-30", + "lts": false, + "latest": "5.12.0" + }, + { + "cycle": "4", + "eol": "2018-04-30", + "support": "2017-04-01", + "lts": "2015-10-01", + "latest": "4.9.1" + }, + { + "cycle": "3", + "eol": true, + "support": false, + "lts": false, + "latest": "3.3.1" + }, + { + "cycle": "2", + "eol": true, + "support": false, + "lts": false, + "latest": "2.5.0" + }, + { + "cycle": "1", + "eol": true, + "support": false, + "lts": false, + "latest": "1.8.4" + } + ], + "laravel": [ + { + "cycle": "13", + "eol": "2028-03-17", + "support": "2027-09-30", + "lts": false, + "latest": "13.42.0" + }, + { + "cycle": "12", + "eol": "2027-02-24", + "support": "2026-08-13", + "lts": false, + "latest": "12.72.0" + }, + { + "cycle": "11", + "eol": "2026-03-12", + "support": "2025-09-03", + "lts": false, + "latest": "11.57.1" + }, + { + "cycle": "10", + "eol": "2025-02-04", + "support": "2024-08-06", + "lts": false, + "latest": "10.50.4" + }, + { + "cycle": "9", + "eol": "2024-02-06", + "support": "2023-08-08", + "lts": false, + "latest": "9.52.23" + }, + { + "cycle": "8", + "eol": "2023-01-24", + "support": "2022-07-26", + "lts": false, + "latest": "8.83.29" + }, + { + "cycle": "7", + "eol": "2021-03-03", + "support": "2020-10-06", + "lts": false, + "latest": "7.30.7" + }, + { + "cycle": "6", + "eol": "2022-09-06", + "support": "2022-01-25", + "lts": true, + "latest": "6.20.45" + }, + { + "cycle": "5.8", + "eol": "2020-02-26", + "support": "2019-08-26", + "lts": false, + "latest": "5.8.38" + }, + { + "cycle": "5.5", + "eol": "2020-08-30", + "support": "2019-08-30", + "lts": true, + "latest": "5.5.50" + } + ], + "symfony": [ + { + "cycle": "8.1", + "eol": "2027-01-31", + "support": "2027-01-31", + "lts": false, + "latest": "8.1.11" + }, + { + "cycle": "8.0", + "eol": "2026-07-31", + "support": "2026-07-31", + "lts": false, + "latest": "8.0.16" + }, + { + "cycle": "7.4", + "eol": "2029-11-30", + "support": "2028-11-30", + "lts": true, + "latest": "7.4.23" + }, + { + "cycle": "7.3", + "eol": "2026-01-31", + "support": "2026-01-31", + "lts": false, + "latest": "7.3.11" + }, + { + "cycle": "7.2", + "eol": "2025-07-31", + "support": "2025-07-31", + "lts": false, + "latest": "7.2.9" + }, + { + "cycle": "7.1", + "eol": "2025-01-31", + "support": "2025-01-31", + "lts": false, + "latest": "7.1.11" + }, + { + "cycle": "7.0", + "eol": "2024-07-31", + "support": "2024-07-31", + "lts": false, + "latest": "7.0.10" + }, + { + "cycle": "6.4", + "eol": "2027-11-30", + "support": "2026-11-30", + "lts": true, + "latest": "6.4.50" + }, + { + "cycle": "6.3", + "eol": "2024-01-31", + "support": "2024-01-31", + "lts": false, + "latest": "6.3.12" + }, + { + "cycle": "6.2", + "eol": "2023-07-31", + "support": "2023-07-31", + "lts": false, + "latest": "6.2.14" + }, + { + "cycle": "6.1", + "eol": "2023-01-31", + "support": "2023-01-31", + "lts": false, + "latest": "6.1.12" + }, + { + "cycle": "6.0", + "eol": "2023-01-31", + "support": "2023-01-31", + "lts": false, + "latest": "6.0.20" + }, + { + "cycle": "5.4", + "eol": "2029-02-28", + "support": "2024-11-30", + "lts": true, + "latest": "5.4.56" + }, + { + "cycle": "5.3", + "eol": "2022-01-01", + "support": "2022-01-01", + "lts": false, + "latest": "5.3.16" + }, + { + "cycle": "5.2", + "eol": "2021-07-21", + "support": "2021-07-21", + "lts": false, + "latest": "5.2.14" + }, + { + "cycle": "5.1", + "eol": "2021-01-21", + "support": "2021-01-21", + "lts": false, + "latest": "5.1.11" + }, + { + "cycle": "5.0", + "eol": "2020-07-21", + "support": "2020-07-21", + "lts": false, + "latest": "5.0.11" + }, + { + "cycle": "4.4", + "eol": "2023-11-21", + "support": "2022-11-21", + "lts": true, + "latest": "4.4.51" + }, + { + "cycle": "4.3", + "eol": "2020-07-01", + "support": "2020-01-01", + "lts": false, + "latest": "4.3.11" + }, + { + "cycle": "4.2", + "eol": "2020-01-01", + "support": "2019-07-01", + "lts": false, + "latest": "4.2.12" + }, + { + "cycle": "4.1", + "eol": "2019-07-01", + "support": "2019-01-01", + "lts": false, + "latest": "4.1.13" + }, + { + "cycle": "4.0", + "eol": "2019-01-01", + "support": "2018-07-01", + "lts": false, + "latest": "4.0.15" + }, + { + "cycle": "3.4", + "eol": "2021-11-01", + "support": "2020-11-01", + "lts": true, + "latest": "3.4.49" + }, + { + "cycle": "3.3", + "eol": "2018-07-01", + "support": "2018-01-01", + "lts": false, + "latest": "3.3.18" + }, + { + "cycle": "3.2", + "eol": "2018-01-01", + "support": "2017-07-01", + "lts": false, + "latest": "3.2.14" + }, + { + "cycle": "3.1", + "eol": "2017-07-01", + "support": "2017-01-01", + "lts": false, + "latest": "3.1.10" + }, + { + "cycle": "3.0", + "eol": "2017-01-01", + "support": "2016-07-01", + "lts": false, + "latest": "3.0.9" + }, + { + "cycle": "2.8", + "eol": "2019-11-01", + "support": "2018-11-01", + "lts": true, + "latest": "2.8.52" + }, + { + "cycle": "2.7", + "eol": "2019-05-01", + "support": "2018-05-01", + "lts": true, + "latest": "2.7.52" + }, + { + "cycle": "2.3", + "eol": "2017-05-01", + "support": "2016-05-01", + "lts": true, + "latest": "2.3.42" + } + ], + "drupal": [ + { + "cycle": "11.4", + "eol": "2027-07-07", + "support": "2027-01-01", + "lts": false, + "latest": "11.4.12" + }, + { + "cycle": "11.3", + "eol": "2026-12-16", + "support": "2026-06-16", + "lts": false, + "latest": "11.3.21" + }, + { + "cycle": "10.6", + "eol": "2026-12-16", + "support": "2026-06-16", + "lts": false, + "latest": "10.6.21" + }, + { + "cycle": "11.2", + "eol": "2026-07-01", + "support": "2025-12-10", + "lts": false, + "latest": "11.2.14" + }, + { + "cycle": "10.5", + "eol": "2026-07-01", + "support": "2025-12-17", + "lts": false, + "latest": "10.5.12" + }, + { + "cycle": "10.4", + "eol": "2025-12-10", + "support": "2025-06-18", + "lts": false, + "latest": "10.4.10" + }, + { + "cycle": "11.1", + "eol": "2025-12-10", + "support": "2025-06-18", + "lts": false, + "latest": "11.1.10" + }, + { + "cycle": "11.0", + "eol": "2025-06-16", + "support": "2024-12-16", + "lts": false, + "latest": "11.0.13" + }, + { + "cycle": "10.3", + "eol": "2025-06-16", + "support": "2024-08-02", + "lts": false, + "latest": "10.3.14" + }, + { + "cycle": "10.2", + "eol": "2024-12-17", + "support": "2024-06-20", + "lts": false, + "latest": "10.2.12" + }, + { + "cycle": "10.1", + "eol": "2024-06-20", + "support": "2023-12-15", + "lts": false, + "latest": "10.1.8" + }, + { + "cycle": "10.0", + "eol": "2023-12-15", + "support": "2023-06-21", + "lts": false, + "latest": "10.0.11" + }, + { + "cycle": "9.5", + "eol": "2023-11-01", + "support": "2023-06-21", + "lts": false, + "latest": "9.5.11" + }, + { + "cycle": "9.4", + "eol": "2023-06-21", + "support": "2022-12-14", + "lts": false, + "latest": "9.4.15" + }, + { + "cycle": "9.3", + "eol": "2022-12-14", + "support": "2022-06-15", + "lts": false, + "latest": "9.3.22" + }, + { + "cycle": "9.2", + "eol": "2022-06-15", + "support": "2021-12-08", + "lts": false, + "latest": "9.2.21" + }, + { + "cycle": "9.1", + "eol": "2021-12-08", + "support": "2021-06-16", + "lts": false, + "latest": "9.1.15" + }, + { + "cycle": "9.0", + "eol": "2021-06-16", + "support": "2020-12-02", + "lts": false, + "latest": "9.0.14" + }, + { + "cycle": "8.9", + "eol": "2021-11-02", + "support": "2020-12-01", + "lts": false, + "latest": "8.9.20" + }, + { + "cycle": "8.8", + "eol": "2020-12-01", + "support": "2020-06-03", + "lts": false, + "latest": "8.8.12" + }, + { + "cycle": "7", + "eol": "2025-01-05", + "support": "2015-11-19", + "lts": true, + "latest": "7.103" + } + ], + "wordpress": [ + { + "cycle": "7.1", + "eol": false, + "support": true, + "lts": false, + "latest": "7.1.4" + }, + { + "cycle": "7.0", + "eol": false, + "support": "2026-08-19", + "lts": false, + "latest": "7.0.8" + }, + { + "cycle": "6.9", + "eol": false, + "support": "2026-05-20", + "lts": false, + "latest": "6.9.11" + }, + { + "cycle": "6.8", + "eol": false, + "support": "2025-12-02", + "lts": false, + "latest": "6.8.12" + }, + { + "cycle": "6.7", + "eol": false, + "support": "2025-04-15", + "lts": false, + "latest": "6.7.11" + }, + { + "cycle": "6.6", + "eol": false, + "support": "2024-11-12", + "lts": false, + "latest": "6.6.11" + }, + { + "cycle": "6.5", + "eol": false, + "support": "2024-07-16", + "lts": false, + "latest": "6.5.14" + }, + { + "cycle": "6.4", + "eol": false, + "support": "2024-04-02", + "lts": false, + "latest": "6.4.14" + }, + { + "cycle": "6.3", + "eol": false, + "support": "2023-11-07", + "lts": false, + "latest": "6.3.14" + }, + { + "cycle": "6.2", + "eol": false, + "support": "2023-08-08", + "lts": false, + "latest": "6.2.15" + }, + { + "cycle": "6.1", + "eol": false, + "support": "2023-03-29", + "lts": false, + "latest": "6.1.16" + }, + { + "cycle": "6.0", + "eol": false, + "support": "2022-11-01", + "lts": false, + "latest": "6.0.18" + }, + { + "cycle": "5.9", + "eol": false, + "support": "2022-05-24", + "lts": false, + "latest": "5.9.20" + }, + { + "cycle": "5.8", + "eol": false, + "support": "2022-01-25", + "lts": false, + "latest": "5.8.19" + }, + { + "cycle": "5.7", + "eol": false, + "support": "2021-07-20", + "lts": false, + "latest": "5.7.21" + }, + { + "cycle": "5.6", + "eol": false, + "support": "2021-03-09", + "lts": false, + "latest": "5.6.23" + }, + { + "cycle": "5.5", + "eol": false, + "support": "2020-12-08", + "lts": false, + "latest": "5.5.24" + }, + { + "cycle": "5.4", + "eol": false, + "support": "2020-08-11", + "lts": false, + "latest": "5.4.25" + }, + { + "cycle": "5.3", + "eol": false, + "support": "2020-03-31", + "lts": false, + "latest": "5.3.27" + }, + { + "cycle": "5.2", + "eol": false, + "support": "2019-11-12", + "lts": false, + "latest": "5.2.30" + }, + { + "cycle": "5.1", + "eol": false, + "support": "2019-05-07", + "lts": false, + "latest": "5.1.28" + }, + { + "cycle": "5.0", + "eol": false, + "support": "2019-02-21", + "lts": false, + "latest": "5.0.31" + }, + { + "cycle": "4.9", + "eol": false, + "support": "2018-12-06", + "lts": false, + "latest": "4.9.35" + }, + { + "cycle": "4.8", + "eol": false, + "support": "2017-11-16", + "lts": false, + "latest": "4.8.34" + }, + { + "cycle": "4.7", + "eol": false, + "support": "2017-06-08", + "lts": false, + "latest": "4.7.39" + }, + { + "cycle": "4.6", + "eol": "2025-07-31", + "support": "2016-12-06", + "lts": false, + "latest": "4.6.30" + }, + { + "cycle": "4.5", + "eol": "2025-07-31", + "support": "2016-08-16", + "lts": false, + "latest": "4.5.33" + }, + { + "cycle": "4.4", + "eol": "2025-07-31", + "support": "2016-04-12", + "lts": false, + "latest": "4.4.34" + }, + { + "cycle": "4.3", + "eol": "2025-07-31", + "support": "2015-12-09", + "lts": false, + "latest": "4.3.35" + }, + { + "cycle": "4.2", + "eol": "2025-07-31", + "support": "2015-08-18", + "lts": false, + "latest": "4.2.39" + }, + { + "cycle": "4.1", + "eol": "2025-07-31", + "support": "2015-04-23", + "lts": false, + "latest": "4.1.42" + }, + { + "cycle": "4.0", + "eol": "2022-12-01", + "support": "2014-12-18", + "lts": false, + "latest": "4.0.38" + }, + { + "cycle": "3.9", + "eol": "2022-12-01", + "support": "2014-09-04", + "lts": false, + "latest": "3.9.40" + }, + { + "cycle": "3.8", + "eol": "2022-12-01", + "support": "2014-04-16", + "lts": false, + "latest": "3.8.41" + }, + { + "cycle": "3.7", + "eol": "2022-12-01", + "support": "2013-12-12", + "lts": false, + "latest": "3.7.41" + }, + { + "cycle": "3.6", + "eol": "2013-10-24", + "support": "2013-10-24", + "lts": false, + "latest": "3.6.1" + }, + { + "cycle": "3.5", + "eol": "2013-08-01", + "support": "2013-08-01", + "lts": false, + "latest": "3.5.2" + }, + { + "cycle": "3.4", + "eol": "2012-12-11", + "support": "2012-12-11", + "lts": false, + "latest": "3.4.2" + }, + { + "cycle": "3.3", + "eol": "2012-06-13", + "support": "2012-06-13", + "lts": false, + "latest": "3.3.3" + }, + { + "cycle": "3.2", + "eol": "2011-12-12", + "support": "2011-12-12", + "lts": false, + "latest": "3.2.1" + }, + { + "cycle": "3.1", + "eol": "2011-07-04", + "support": "2011-07-04", + "lts": false, + "latest": "3.1.4" + }, + { + "cycle": "3.0", + "eol": "2011-02-23", + "support": "2011-02-23", + "lts": false, + "latest": "3.0.6" + }, + { + "cycle": "2.9", + "eol": "2010-06-17", + "support": "2010-06-17", + "lts": false, + "latest": "2.9.2" + }, + { + "cycle": "2.8", + "eol": "2009-12-18", + "support": "2009-12-18", + "lts": false, + "latest": "2.8.6" + }, + { + "cycle": "2.7", + "eol": "2009-09-10", + "support": "2009-09-10", + "lts": false, + "latest": "2.7.1" + }, + { + "cycle": "2.6", + "eol": "2008-12-10", + "support": "2008-12-10", + "lts": false, + "latest": "2.6.5" + }, + { + "cycle": "2.5", + "eol": "2008-07-14", + "support": "2008-07-14", + "lts": false, + "latest": "2.5.1" + }, + { + "cycle": "2.3", + "eol": "2008-03-29", + "support": "2008-03-29", + "lts": false, + "latest": "2.3.3" + }, + { + "cycle": "2.2", + "eol": "2007-09-24", + "support": "2007-09-24", + "lts": false, + "latest": "2.2.3" + }, + { + "cycle": "2.1", + "eol": "2007-09-24", + "support": "2007-09-24", + "lts": false, + "latest": "2.1.3" + }, + { + "cycle": "2.0", + "eol": "2007-08-05", + "support": "2007-08-05", + "lts": false, + "latest": "2.0.11" + }, + { + "cycle": "1.5", + "eol": "2005-12-26", + "support": "2005-12-26", + "lts": false, + "latest": "1.5.2" + }, + { + "cycle": "1.2", + "eol": "2005-02-17", + "support": "2005-02-17", + "lts": false, + "latest": "1.2.1" + }, + { + "cycle": "1.0", + "eol": "2004-05-22", + "support": "2004-05-22", + "lts": false, + "latest": "1.0.2" + }, + { + "cycle": "0.72", + "eol": "2004-01-03", + "support": "2004-01-03", + "lts": false, + "latest": "0.72" + }, + { + "cycle": "0.71", + "eol": "2003-10-11", + "support": "2003-10-11", + "lts": false, + "latest": "0.711" + } + ], + "jquery": [ + { + "cycle": "4", + "eol": false, + "support": true, + "lts": false, + "latest": "4.0.0" + }, + { + "cycle": "3", + "eol": false, + "support": "2026-01-17", + "lts": false, + "latest": "3.7.1" + }, + { + "cycle": "2", + "eol": true, + "support": false, + "lts": false, + "latest": "2.2.4" + }, + { + "cycle": "1", + "eol": true, + "support": false, + "lts": false, + "latest": "1.12.4" + } + ], + "bootstrap": [ + { + "cycle": "5", + "eol": false, + "support": true, + "lts": "2022-07-19", + "latest": "5.3.9" + }, + { + "cycle": "4", + "eol": "2023-01-01", + "support": "2021-11-01", + "lts": "2019-11-26", + "latest": "4.6.2" + }, + { + "cycle": "3", + "eol": "2019-07-24", + "support": "2016-09-05", + "lts": "2014-11-01", + "latest": "3.4.1" + }, + { + "cycle": "2", + "eol": "2013-08-19", + "support": "2013-08-19", + "lts": false, + "latest": "2.3.2" + } + ], + "angularjs": [ + { + "cycle": "1.8", + "eol": "2021-12-31", + "support": null, + "lts": true, + "latest": "1.8.3" + }, + { + "cycle": "1.7", + "eol": "2021-12-31", + "support": null, + "lts": false, + "latest": "1.7.9" + }, + { + "cycle": "1.6", + "eol": "2021-12-31", + "support": null, + "lts": false, + "latest": "1.6.10" + }, + { + "cycle": "1.5", + "eol": "2021-12-31", + "support": null, + "lts": false, + "latest": "1.5.11" + }, + { + "cycle": "1.4", + "eol": "2021-12-31", + "support": null, + "lts": false, + "latest": "1.4.14" + }, + { + "cycle": "1.3", + "eol": "2021-12-31", + "support": null, + "lts": false, + "latest": "1.3.20" + }, + { + "cycle": "1.2", + "eol": "2021-12-31", + "support": null, + "lts": false, + "latest": "1.2.32" + }, + { + "cycle": "1.1", + "eol": "2021-12-31", + "support": null, + "lts": false, + "latest": "1.1.5" + }, + { + "cycle": "1.0", + "eol": "2021-12-31", + "support": null, + "lts": false, + "latest": "1.0.8" + } + ], + "vue": [ + { + "cycle": "3.5", + "eol": false, + "support": true, + "lts": false, + "latest": "3.5.45" + }, + { + "cycle": "3.4", + "eol": "2024-09-03", + "support": "2024-09-03", + "lts": false, + "latest": "3.4.38" + }, + { + "cycle": "3.3", + "eol": "2023-12-29", + "support": "2023-12-29", + "lts": false, + "latest": "3.3.13" + }, + { + "cycle": "2.7", + "eol": "2023-12-31", + "support": "2023-12-31", + "lts": false, + "latest": "2.7.16" + }, + { + "cycle": "3.2", + "eol": "2023-05-11", + "support": "2023-05-11", + "lts": false, + "latest": "3.2.47" + }, + { + "cycle": "3.1", + "eol": "2021-08-09", + "support": "2021-08-09", + "lts": false, + "latest": "3.1.5" + }, + { + "cycle": "3.0", + "eol": "2021-06-07", + "support": "2021-06-07", + "lts": false, + "latest": "3.0.11" + }, + { + "cycle": "2.6", + "eol": "2022-07-01", + "support": "2022-07-01", + "lts": false, + "latest": "2.6.14" + }, + { + "cycle": "2.5", + "eol": "2019-02-04", + "support": "2019-02-04", + "lts": false, + "latest": "2.5.22" + }, + { + "cycle": "2.4", + "eol": "2017-10-13", + "support": "2017-10-13", + "lts": false, + "latest": "2.4.4" + }, + { + "cycle": "2.3", + "eol": "2017-07-13", + "support": "2017-07-13", + "lts": false, + "latest": "2.3.4" + }, + { + "cycle": "2.2", + "eol": "2017-04-27", + "support": "2017-04-27", + "lts": false, + "latest": "2.2.6" + }, + { + "cycle": "2.1", + "eol": "2017-02-26", + "support": "2017-02-26", + "lts": false, + "latest": "2.1.10" + }, + { + "cycle": "2.0", + "eol": "2016-11-22", + "support": "2016-11-22", + "lts": false, + "latest": "2.0.8" + }, + { + "cycle": "1", + "eol": true, + "support": false, + "lts": false, + "latest": "1.0.28" + } + ] + } +} diff --git a/data/js-libs.json b/data/js-libs.json new file mode 100644 index 0000000..bdd1e68 --- /dev/null +++ b/data/js-libs.json @@ -0,0 +1,2682 @@ +{ + "source": "https://osv.dev (npm ecosystem)", + "asOf": "2026-11-13", + "note": "Advisories for front-end libraries that are often copied into web projects. Refreshed with npm run update-data; --online scans query OSV.dev directly.", + "packages": { + "jquery": [ + { + "id": "GHSA-2pqj-h3vj-pqgw", + "aliases": [ + "CVE-2012-6708" + ], + "summary": "Cross-Site Scripting in jquery", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.9.0" + } + ] + ] + }, + { + "id": "GHSA-579v-mp3v-rrw5", + "aliases": [ + "CVE-2011-4969" + ], + "summary": "jQuery vulnerable to Cross-Site Scripting (XSS)", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.6.3" + } + ] + ] + }, + { + "id": "GHSA-6c3j-c64m-qhgq", + "aliases": [ + "CVE-2019-11358" + ], + "summary": "XSS in jQuery as used in Drupal, Backdrop CMS, and other products", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "1.1.4" + }, + { + "fixed": "3.4.0" + } + ] + ] + }, + { + "id": "GHSA-gxr4-xjj5-5px2", + "aliases": [ + "CVE-2020-11022" + ], + "summary": "Potential XSS vulnerability in jQuery", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "1.12.0" + }, + { + "fixed": "3.5.0" + } + ] + ] + }, + { + "id": "GHSA-jpcq-cgw6-v4j6", + "aliases": [ + "CVE-2020-11023" + ], + "summary": "Potential XSS vulnerability in jQuery", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "1.0.3" + }, + { + "fixed": "3.5.0" + } + ] + ] + }, + { + "id": "GHSA-mhpp-875w-9cpv", + "aliases": [ + "CVE-2016-10707" + ], + "summary": "Denial of Service in jquery", + "severity": "high", + "ranges": [ + [ + { + "introduced": "3.0.0-rc.1" + }, + { + "fixed": "3.0.0" + } + ] + ] + }, + { + "id": "GHSA-q4m3-2j7h-f7xw", + "aliases": [ + "CVE-2020-7656" + ], + "summary": "Cross-Site Scripting in jquery", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "1.2.1" + }, + { + "fixed": "1.9.0" + } + ] + ] + }, + { + "id": "GHSA-rmxg-73gg-4p98", + "aliases": [ + "CVE-2015-9251" + ], + "summary": "Cross-Site Scripting (XSS) in jquery", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.12.2" + } + ], + [ + { + "introduced": "1.12.3" + }, + { + "fixed": "3.0.0" + } + ] + ] + } + ], + "jquery-ui": [ + { + "id": "GHSA-9gj3-hwp5-pmwc", + "aliases": [ + "CVE-2021-41182" + ], + "summary": "XSS in the `altField` option of the Datepicker widget in jquery-ui", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.13.0" + } + ] + ] + }, + { + "id": "GHSA-gpqq-952q-5327", + "aliases": [ + "CVE-2021-41184" + ], + "summary": "XSS in the `of` option of the `.position()` util in jquery-ui", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.13.0" + } + ] + ] + }, + { + "id": "GHSA-h6gj-6jjq-h8g9", + "aliases": [ + "CVE-2022-31160" + ], + "summary": "jQuery UI vulnerable to XSS when refreshing a checkboxradio with an HTML-like initial text label", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.13.2" + } + ] + ] + }, + { + "id": "GHSA-hpcf-8vf9-q4gj", + "aliases": [ + "CVE-2016-7103" + ], + "summary": "jQuery-UI vulnerable to Cross-site Scripting in dialog closeText", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.12.0" + } + ] + ] + }, + { + "id": "GHSA-j7qv-pgf6-hvh4", + "aliases": [ + "CVE-2021-41183" + ], + "summary": "XSS in `*Text` options of the Datepicker widget in jquery-ui", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.13.0" + } + ] + ] + }, + { + "id": "GHSA-qqxp-xp9v-vvx6", + "aliases": [ + "CVE-2012-6662" + ], + "summary": "jquery-ui Tooltip widget vulnerable to XSS", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.10.0" + } + ] + ] + }, + { + "id": "GHSA-wcm2-9c89-wmfm", + "aliases": [ + "CVE-2010-5312" + ], + "summary": "Cross-site Scripting in jquery-ui", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "1.7.0" + }, + { + "fixed": "1.10.0" + } + ] + ] + } + ], + "bootstrap": [ + { + "id": "GHSA-3mgp-fx93-9xv5", + "aliases": [ + "CVE-2018-20676" + ], + "summary": "XSS vulnerability that affects bootstrap", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.4.0" + } + ] + ] + }, + { + "id": "GHSA-3wqf-4x89-9g79", + "aliases": [ + "CVE-2018-14040" + ], + "summary": "Bootstrap vulnerable to Cross-Site Scripting (XSS)", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.1.2" + } + ], + [ + { + "introduced": "2.3.0" + }, + { + "fixed": "3.4.0" + } + ] + ] + }, + { + "id": "GHSA-4p24-vmcr-4gqj", + "aliases": [ + "CVE-2016-10735" + ], + "summary": "Bootstrap Cross-site Scripting vulnerability", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "2.0.4" + }, + { + "fixed": "3.4.0" + } + ], + [ + { + "introduced": "4.0.0-beta" + }, + { + "fixed": "4.0.0-beta.2" + } + ] + ] + }, + { + "id": "GHSA-7mvr-5x2g-wfc8", + "aliases": [ + "CVE-2018-14042" + ], + "summary": "Bootstrap Cross-site Scripting vulnerability", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.1.2" + } + ], + [ + { + "introduced": "2.3.0" + }, + { + "fixed": "3.4.0" + } + ] + ] + }, + { + "id": "GHSA-9v3m-8fp8-mj99", + "aliases": [ + "CVE-2019-8331" + ], + "summary": "Bootstrap Vulnerable to Cross-Site Scripting", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.3.1" + } + ], + [ + { + "introduced": "3.0.0" + }, + { + "fixed": "3.4.1" + } + ] + ] + }, + { + "id": "GHSA-ph58-4vrj-w6hr", + "aliases": [ + "CVE-2018-20677" + ], + "summary": "bootstrap Cross-site Scripting vulnerability", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.4.0" + } + ] + ] + }, + { + "id": "GHSA-pj7m-g53m-7638", + "aliases": [ + "CVE-2018-14041" + ], + "summary": "Bootstrap Cross-site Scripting vulnerability", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.1.2" + } + ] + ] + }, + { + "id": "GHSA-q58r-hwc8-rm9j", + "aliases": [ + "CVE-2025-1647" + ], + "summary": "Bootstrap Vulnerable to Cross-Site Scripting in its Popover and Tooltip Components", + "severity": "medium", + "ranges": [], + "versions": [ + "3.4.1" + ] + }, + { + "id": "GHSA-vxmc-5x29-h64v", + "aliases": [ + "CVE-2024-6485" + ], + "summary": "Bootstrap Cross-Site Scripting (XSS) vulnerability for data-* attributes", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "1.4.0" + }, + { + "last_affected": "3.4.1" + } + ] + ] + } + ], + "angular": [ + { + "id": "GHSA-28hp-fgcr-2r4h", + "aliases": [], + "summary": "Cross-Site Scripting via JSONP", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.6.0" + } + ] + ] + }, + { + "id": "GHSA-2qqx-w9hr-q5gx", + "aliases": [ + "CVE-2023-26117" + ], + "summary": "angular vulnerable to regular expression denial of service via the $resource service", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "last_affected": "1.8.3" + } + ] + ] + }, + { + "id": "GHSA-2vrf-hf26-jrp5", + "aliases": [ + "CVE-2023-26116" + ], + "summary": "angular vulnerable to regular expression denial of service via the angular.copy() utility", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "last_affected": "1.8.3" + } + ] + ] + }, + { + "id": "GHSA-4w4v-5hc9-xrr2", + "aliases": [ + "CVE-2024-21490" + ], + "summary": "angular vulnerable to super-linear runtime due to backtracking", + "severity": "high", + "ranges": [ + [ + { + "introduced": "1.3.0" + }, + { + "last_affected": "1.8.3" + } + ] + ] + }, + { + "id": "GHSA-5cp4-xmrw-59wf", + "aliases": [], + "summary": "XSS via JQLite DOM manipulation functions in AngularJS", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.8.0" + } + ] + ] + }, + { + "id": "GHSA-7x27-g8rg-x87w", + "aliases": [ + "CVE-2026-11998" + ], + "summary": "Angular's deprecated package has a Cross-Site Scripting issue", + "severity": "high", + "ranges": [ + [ + { + "introduced": "1.2.0-rc.3" + }, + { + "last_affected": "1.8.3" + } + ] + ] + }, + { + "id": "GHSA-89mq-4x47-5v83", + "aliases": [ + "CVE-2019-10768" + ], + "summary": "angular Prototype Pollution vulnerability", + "severity": "high", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.7.9" + } + ] + ] + }, + { + "id": "GHSA-j58c-ww9w-pwp5", + "aliases": [ + "CVE-2025-0716" + ], + "summary": "AngularJS improperly sanitizes SVG elements", + "severity": "low", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "last_affected": "1.8.3" + } + ] + ] + }, + { + "id": "GHSA-m2h2-264f-f486", + "aliases": [ + "CVE-2022-25844" + ], + "summary": "angular vulnerable to regular expression denial of service (ReDoS)", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "1.7.0" + } + ] + ] + }, + { + "id": "GHSA-m9gf-397r-hwpg", + "aliases": [ + "CVE-2024-8372" + ], + "summary": "AngularJS allows attackers to bypass common image source restrictions", + "severity": "low", + "ranges": [ + [ + { + "introduced": "1.3.0-rc.4" + }, + { + "last_affected": "1.8.3" + } + ] + ] + }, + { + "id": "GHSA-mhp6-pxh8-r675", + "aliases": [ + "CVE-2020-7676" + ], + "summary": "Angular vulnerable to Cross-site Scripting", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.8.0" + } + ] + ] + }, + { + "id": "GHSA-mqm9-c95h-x2p6", + "aliases": [ + "CVE-2024-8373" + ], + "summary": "AngularJS allows attackers to bypass common image source restrictions", + "severity": "low", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "last_affected": "1.8.3" + } + ] + ] + }, + { + "id": "GHSA-prc3-vjfx-vhm9", + "aliases": [ + "CVE-2022-25869" + ], + "summary": "Angular (deprecated package) Cross-site Scripting", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "last_affected": "1.8.3" + } + ] + ] + }, + { + "id": "GHSA-qwqh-hm9m-p5hr", + "aliases": [ + "CVE-2023-26118" + ], + "summary": "angular vulnerable to regular expression denial of service via the element", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "last_affected": "1.8.3" + } + ] + ] + }, + { + "id": "GHSA-r5fx-8r73-v86c", + "aliases": [ + "CVE-2019-14863" + ], + "summary": "AngularJS Cross-site Scripting due to failure to sanitize `xlink.href` attributes", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.5.0-beta.1" + } + ] + ] + } + ], + "lodash": [ + { + "id": "GHSA-29mw-wpgm-hmr9", + "aliases": [ + "CVE-2020-28500" + ], + "summary": "Regular Expression Denial of Service (ReDoS) in lodash", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.17.21" + } + ] + ] + }, + { + "id": "GHSA-35jh-r3h4-6jhm", + "aliases": [ + "CVE-2021-23337" + ], + "summary": "Command Injection in lodash", + "severity": "high", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "4.17.21" + } + ] + ] + }, + { + "id": "GHSA-4xc9-xhrj-v574", + "aliases": [ + "CVE-2018-16487" + ], + "summary": "Prototype Pollution in lodash", + "severity": "high", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "4.17.11" + } + ] + ] + }, + { + "id": "GHSA-f23m-r3pf-42rh", + "aliases": [ + "CVE-2026-2950" + ], + "summary": "lodash vulnerable to prototype pollution via array-path bypass in `_.unset`, `_.omit`, and `_.pullAt", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "4.17.23" + }, + { + "fixed": "4.18.1" + } + ] + ] + }, + { + "id": "GHSA-fvqr-27wr-82fm", + "aliases": [ + "CVE-2018-3721" + ], + "summary": "Prototype Pollution in lodash", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "4.17.5" + } + ] + ] + }, + { + "id": "GHSA-jf85-cpcp-j695", + "aliases": [ + "CVE-2019-10744" + ], + "summary": "Prototype Pollution in lodash", + "severity": "critical", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "4.17.12" + } + ] + ] + }, + { + "id": "GHSA-p6mc-m468-83gw", + "aliases": [ + "CVE-2020-8203" + ], + "summary": "Prototype Pollution in lodash", + "severity": "high", + "ranges": [ + [ + { + "introduced": "3.7.0" + }, + { + "fixed": "4.17.19" + } + ] + ] + }, + { + "id": "GHSA-r5fr-rjxr-66jc", + "aliases": [ + "CVE-2026-4800" + ], + "summary": "lodash vulnerable to Code Injection via `_.template` imports key names", + "severity": "high", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.18.0" + } + ] + ] + }, + { + "id": "GHSA-x5rq-j2xg-h7qm", + "aliases": [ + "CVE-2019-1010266" + ], + "summary": "Regular Expression Denial of Service (ReDoS) in lodash", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "4.7.0" + }, + { + "fixed": "4.17.11" + } + ] + ] + }, + { + "id": "GHSA-xxjr-mmjv-4gpg", + "aliases": [ + "CVE-2025-13465" + ], + "summary": "Lodash has Prototype Pollution Vulnerability in `_.unset`, `_.omit`, and `_.pullAt` functions", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.17.23" + } + ] + ] + } + ], + "underscore": [ + { + "id": "GHSA-cf4h-3jhx-xvhq", + "aliases": [ + "CVE-2021-23358" + ], + "summary": "Arbitrary Code Execution in underscore", + "severity": "critical", + "ranges": [ + [ + { + "introduced": "1.3.2" + }, + { + "fixed": "1.12.1" + } + ] + ] + }, + { + "id": "GHSA-qpx9-hpmf-5gmw", + "aliases": [ + "CVE-2026-27601" + ], + "summary": "Underscore has unlimited recursion in _.flatten and _.isEqual, potential for DoS attack", + "severity": "high", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.13.8" + } + ] + ] + } + ], + "moment": [ + { + "id": "GHSA-446m-mv8f-q348", + "aliases": [ + "CVE-2017-18214" + ], + "summary": "Regular Expression Denial of Service in moment", + "severity": "high", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "2.19.3" + } + ] + ] + }, + { + "id": "GHSA-4p3w-j4w9-5jqw", + "aliases": [ + "CVE-2026-17495" + ], + "summary": "moment vulnerable to Path Traversal via crafted non-string locale name", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "2.29.2" + }, + { + "fixed": "2.31.0" + } + ] + ] + }, + { + "id": "GHSA-87vv-r9j6-g5qv", + "aliases": [ + "CVE-2016-4055" + ], + "summary": "Regular Expression Denial of Service in moment", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "2.11.2" + } + ] + ] + }, + { + "id": "GHSA-8hfj-j24r-96c4", + "aliases": [ + "CVE-2022-24785" + ], + "summary": "Path Traversal: 'dir/../../filename' in moment.locale", + "severity": "high", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "2.29.2" + } + ] + ] + }, + { + "id": "GHSA-wc69-rhjr-hc9g", + "aliases": [ + "CVE-2022-31129" + ], + "summary": "Moment.js vulnerable to Inefficient Regular Expression Complexity", + "severity": "high", + "ranges": [ + [ + { + "introduced": "2.18.0" + }, + { + "fixed": "2.29.4" + } + ] + ] + } + ], + "handlebars": [ + { + "id": "GHSA-2cf5-4w76-r9qv", + "aliases": [], + "summary": "Arbitrary Code Execution in handlebars", + "severity": "high", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.0.8" + } + ], + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.5.2" + } + ] + ] + }, + { + "id": "GHSA-2qvq-rjwj-gvw9", + "aliases": [ + "CVE-2026-33916" + ], + "summary": "Handlebars.js has Prototype Pollution Leading to XSS through Partial Template Injection", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.7.9" + } + ] + ] + }, + { + "id": "GHSA-2w6w-674q-4c4q", + "aliases": [ + "CVE-2026-33937" + ], + "summary": "Handlebars.js has JavaScript Injection via AST Type Confusion", + "severity": "critical", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.7.9" + } + ] + ] + }, + { + "id": "GHSA-3cqr-58rm-57f8", + "aliases": [ + "CVE-2019-20920" + ], + "summary": "Arbitrary Code Execution in Handlebars", + "severity": "high", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.0.8" + } + ], + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.5.3" + } + ] + ] + }, + { + "id": "GHSA-3mfm-83xf-c92r", + "aliases": [ + "CVE-2026-33938" + ], + "summary": "Handlebars.js has JavaScript Injection via AST Type Confusion by tampering @partial-block", + "severity": "high", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.7.9" + } + ] + ] + }, + { + "id": "GHSA-442j-39wm-28r2", + "aliases": [], + "summary": "Handlebars.js has a Property Access Validation Bypass in container.lookup", + "severity": "low", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.7.9" + } + ] + ] + }, + { + "id": "GHSA-62gr-4qp9-h98f", + "aliases": [ + "CVE-2019-20922" + ], + "summary": "Regular Expression Denial of Service in Handlebars", + "severity": "high", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.4.5" + } + ] + ] + }, + { + "id": "GHSA-765h-qjxv-5f44", + "aliases": [ + "CVE-2021-23383" + ], + "summary": "Prototype Pollution in handlebars", + "severity": "critical", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "4.7.7" + } + ] + ] + }, + { + "id": "GHSA-7rx3-28cr-v5wh", + "aliases": [], + "summary": "Handlebars.js has a Prototype Method Access Control Gap via Missing __lookupSetter__ Blocklist Entry", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "4.6.0" + }, + { + "fixed": "4.7.9" + } + ] + ] + }, + { + "id": "GHSA-8r5x-fm3f-whwj", + "aliases": [ + "CVE-2026-106446" + ], + "summary": "Handlebars: JavaScript Injection via AST Type Confusion in compile (bypass of CVE-2026-33937)", + "severity": "critical", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.7.10" + } + ] + ] + }, + { + "id": "GHSA-9cx6-37pm-9jff", + "aliases": [ + "CVE-2026-33939" + ], + "summary": "Handlebars.js has Denial of Service via Malformed Decorator Syntax in Template Compilation", + "severity": "high", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.7.9" + } + ] + ] + }, + { + "id": "GHSA-9prh-257w-9277", + "aliases": [ + "CVE-2015-8861" + ], + "summary": "Cross-Site Scripting in handlebars", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "4.0.0" + } + ] + ] + }, + { + "id": "GHSA-f2jv-r9rf-7988", + "aliases": [ + "CVE-2021-23369" + ], + "summary": "Remote code execution in handlebars when compiling templates", + "severity": "critical", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "4.7.7" + } + ] + ] + }, + { + "id": "GHSA-f52g-6jhx-586p", + "aliases": [], + "summary": "Denial of Service in handlebars", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.4.5" + } + ] + ] + }, + { + "id": "GHSA-g9r4-xpmj-mj65", + "aliases": [], + "summary": "Prototype Pollution in handlebars", + "severity": "high", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.0.8" + } + ], + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.5.3" + } + ] + ] + }, + { + "id": "GHSA-p8wg-vrv2-v86f", + "aliases": [ + "CVE-2026-106445" + ], + "summary": "Handlebars: JavaScript Injection via Own Property Check Bypass", + "severity": "critical", + "ranges": [ + [ + { + "introduced": "3.0.0" + }, + { + "fixed": "4.7.10" + } + ] + ] + }, + { + "id": "GHSA-q2c6-c6pm-g3gh", + "aliases": [], + "summary": "Arbitrary Code Execution in handlebars", + "severity": "high", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.0.8" + } + ], + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.5.3" + } + ] + ] + }, + { + "id": "GHSA-q42p-pg8m-cqh6", + "aliases": [], + "summary": "Prototype Pollution in handlebars", + "severity": "high", + "ranges": [ + [ + { + "introduced": "4.1.0" + }, + { + "fixed": "4.1.2" + } + ], + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.0.14" + } + ], + [ + { + "introduced": "0" + }, + { + "fixed": "3.0.7" + } + ] + ] + }, + { + "id": "GHSA-w457-6q6x-cgp9", + "aliases": [ + "CVE-2019-19919" + ], + "summary": "Prototype Pollution in handlebars", + "severity": "critical", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.3.0" + } + ], + [ + { + "introduced": "0" + }, + { + "fixed": "3.0.8" + } + ] + ] + }, + { + "id": "GHSA-xhpv-hc6g-r9c6", + "aliases": [ + "CVE-2026-33940" + ], + "summary": "Handlebars.js has JavaScript Injection via AST Type Confusion when passing an object as dynamic partial", + "severity": "high", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.7.9" + } + ] + ] + }, + { + "id": "GHSA-xjpj-3mr7-gcpf", + "aliases": [ + "CVE-2026-33941" + ], + "summary": "Handlebars.js has JavaScript Injection in CLI Precompiler via Unescaped Names and Options", + "severity": "high", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.7.9" + } + ] + ] + }, + { + "id": "GHSA-xw65-4hp5-5hc7", + "aliases": [ + "CVE-2026-106444" + ], + "summary": "Handlebars: JavaScript Injection via Unsafe Inline Embedding of Precompiled Templates", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "4.0.0" + }, + { + "fixed": "4.7.10" + } + ] + ] + } + ], + "vue": [ + { + "id": "GHSA-5j4c-8p2g-v4jx", + "aliases": [ + "CVE-2024-9506" + ], + "summary": "ReDoS vulnerability in vue package that is exploitable through inefficient regex evaluation in the parseHTML function", + "severity": "low", + "ranges": [ + [ + { + "introduced": "2.0.0-alpha.1" + }, + { + "fixed": "3.0.0-alpha.0" + } + ] + ] + } + ], + "dompurify": [ + { + "id": "GHSA-39q2-94rc-95cp", + "aliases": [ + "CVE-2026-65903" + ], + "summary": "DOMPurify's ADD_TAGS function form bypasses FORBID_TAGS due to short-circuit evaluation", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.4.0" + } + ] + ] + }, + { + "id": "GHSA-55q2-fjhq-7xh7", + "aliases": [ + "CVE-2026-75838" + ], + "summary": "DOMPurify: IN_PLACE hook removal leaves a detached subtree executable, causing XSS", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.4.13" + } + ] + ] + }, + { + "id": "GHSA-63q7-h895-m982", + "aliases": [ + "CVE-2020-26870" + ], + "summary": "Cross-site Scripting in dompurify", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "2.0.17" + } + ] + ] + }, + { + "id": "GHSA-6688-9rhm-gjv2", + "aliases": [ + "CVE-2026-109345" + ], + "summary": "DOMPurify: IN_PLACE returns a force-removed rawtext root whose text carries attacker markup — pure HTML reparse executes", + "severity": "low", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.4.16" + } + ] + ] + }, + { + "id": "GHSA-76mc-f452-cxcm", + "aliases": [ + "CVE-2026-65902" + ], + "summary": "DOMPurify: Hook mutation of `data.allowedTags` / `data.allowedAttributes` permanently pollutes `DEFAULT_ALLOWED_TAGS` / `DEFAULT_ALLOWED_ATTR`", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.4.7" + } + ] + ] + }, + { + "id": "GHSA-87xg-pxx2-7hvx", + "aliases": [ + "CVE-2026-47423" + ], + "summary": "DOMPurify XSS via selectedcontent re-clone", + "severity": "high", + "ranges": [ + [ + { + "introduced": "3.4.4" + }, + { + "fixed": "3.4.5" + } + ] + ] + }, + { + "id": "GHSA-8hgg-xxm5-3873", + "aliases": [ + "CVE-2019-25155" + ], + "summary": "DOMPurify Open Redirect vulnerability", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "1.0.11" + } + ] + ] + }, + { + "id": "GHSA-c2j3-45gr-mqc4", + "aliases": [ + "CVE-2026-66010" + ], + "summary": "DOMPurify: `CUSTOM_ELEMENT_HANDLING` bypasses `afterSanitizeElements` for allowed custom elements.", + "severity": "low", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.4.12" + } + ] + ] + }, + { + "id": "GHSA-c6gr-qvv4-5v3f", + "aliases": [ + "CVE-2026-116802" + ], + "summary": "DOMPurify: SMIL attributeName=href guard is skipped when PARSER_MEDIA_TYPE is application/xhtml+xml", + "severity": "low", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.4.17" + } + ] + ] + }, + { + "id": "GHSA-cg2g-xh64-v4q7", + "aliases": [ + "CVE-2026-116804" + ], + "summary": "DOMPurify SAFE_FOR_TEMPLATES bypass: split template expressions survive in attached shadow root content on DOM output modes", + "severity": "critical", + "ranges": [ + [ + { + "introduced": "3.4.4" + }, + { + "fixed": "3.4.17" + } + ] + ] + }, + { + "id": "GHSA-chqj-j4fh-rw7m", + "aliases": [ + "CVE-2019-16728" + ], + "summary": "Cross-Site Scripting in dompurify", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "2.0.3" + } + ] + ] + }, + { + "id": "GHSA-cj63-jhhr-wcxv", + "aliases": [ + "CVE-2026-65913" + ], + "summary": "DOMPurify USE_PROFILES prototype pollution allows event handlers", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.3.2" + } + ] + ] + }, + { + "id": "GHSA-cjmm-f4jc-qw8r", + "aliases": [ + "CVE-2026-65912" + ], + "summary": "DOMPurify ADD_ATTR predicate skips URI validation", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.3.2" + } + ] + ] + }, + { + "id": "GHSA-cmwh-pvxp-8882", + "aliases": [ + "CVE-2026-65898" + ], + "summary": "DOMPurify: Permanent `ALLOWED_ATTR` pollution via `setConfig()` bypassing the hook clone-guard (incomplete fix of the 3.4.7 hook-pollution patch)", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "0" + }, + { + "fixed": "3.4.11" + } + ] + ] + }, + { + "id": "GHSA-crv5-9vww-q3g8", + "aliases": [ + "CVE-2026-41239" + ], + "summary": "DOMPurify has a SAFE_FOR_TEMPLATES bypass in RETURN_DOM mode", + "severity": "medium", + "ranges": [ + [ + { + "introduced": "1.0.10" + }, + { + "fixed": "3.4.0" + } + ] + ] + }, + { + "id": "GHSA-gvmj-g25r-r7wr", + "aliases": [ + "CVE-2026-65900" + ], + "summary": "DOMPurify: SAFE_FOR_TEMPLATES bypass - template expressions survive sanitization inside