loadwise 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PERFORMANCE.md +17 -0
- package/README.md +294 -700
- package/agent/hooks/check-edited-file.mjs +800 -0
- package/dist/bin/github-action.js +72 -18
- package/dist/bin/loadwise.js +21 -34
- package/dist/lib/accessibility/angular-literal.js +1 -1
- package/dist/lib/accessibility/aria-tables.js +10 -6
- package/dist/lib/accessibility/astro-template.js +111 -0
- package/dist/lib/accessibility/autofocus.js +94 -0
- package/dist/lib/accessibility/document-reference-rules.js +143 -0
- package/dist/lib/accessibility/form-context.js +7 -2
- package/dist/lib/accessibility/frontend-detect.js +18 -8
- package/dist/lib/accessibility/heading-order.js +59 -0
- package/dist/lib/accessibility/interaction-semantics.js +90 -0
- package/dist/lib/accessibility/jinja-template.js +150 -0
- package/dist/lib/accessibility/jsx-elements.js +164 -21
- package/dist/lib/accessibility/language-tags.js +18 -0
- package/dist/lib/accessibility/markup-files.js +44 -17
- package/dist/lib/accessibility/markup.js +4 -1
- package/dist/lib/accessibility/media-rules.js +81 -0
- package/dist/lib/accessibility/native-interactive.js +145 -0
- package/dist/lib/accessibility/rule-ids.js +30 -0
- package/dist/lib/accessibility/rule-utilities.js +92 -0
- package/dist/lib/accessibility/rules.js +77 -140
- package/dist/lib/accessibility/site-fixes/aria-typo.js +65 -0
- package/dist/lib/accessibility/site-fixes/buttons.js +4 -11
- package/dist/lib/accessibility/site-fixes/email-autocomplete.js +103 -0
- package/dist/lib/accessibility/site-fixes/html-language.js +84 -0
- package/dist/lib/accessibility/site-fixes/media-autoplay.js +87 -0
- package/dist/lib/accessibility/site-fixes/positive-tabindex.js +102 -0
- package/dist/lib/accessibility/site-fixes/source-position.js +11 -0
- package/dist/lib/accessibility/site-fixes/viewport.js +107 -0
- package/dist/lib/accessibility/table-headers.js +70 -0
- package/dist/lib/accessibility/template-attributes.js +13 -2
- package/dist/lib/accessibility/template-binding-scope.js +122 -0
- package/dist/lib/accessibility/template-elements.js +259 -109
- package/dist/lib/accessibility/template-file.js +111 -22
- package/dist/lib/accessibility/template-tag-tables.js +86 -0
- package/dist/lib/accessibility/usage.js +1 -1
- package/dist/lib/editor/accessibility-examples.js +5 -0
- package/dist/lib/editor/actions.js +26 -14
- package/dist/lib/editor/apply-fix.js +30 -2
- package/dist/lib/editor/configured-setup.js +9 -14
- package/dist/lib/editor/diagnostics.js +121 -135
- package/dist/lib/editor/dismissals.js +21 -10
- package/dist/lib/editor/doctor.js +167 -0
- package/dist/lib/editor/editor-document.js +17 -1
- package/dist/lib/editor/editor-launcher.js +60 -26
- package/dist/lib/editor/finding-comparison.js +4 -25
- package/dist/lib/editor/fix-edits.js +87 -8
- package/dist/lib/editor/hover-markdown.js +104 -0
- package/dist/lib/editor/inline-fix.js +50 -0
- package/dist/lib/editor/inline-recommendation.js +27 -0
- package/dist/lib/editor/jetbrains-setup.js +2 -1
- package/dist/lib/editor/language-server.js +305 -56
- package/dist/lib/editor/native-setup.js +7 -2
- package/dist/lib/editor/perf-watch.js +7 -5
- package/dist/lib/editor/performance-examples.js +31 -0
- package/dist/lib/editor/polyglot-selection.js +193 -0
- package/dist/lib/editor/project-policy.js +146 -0
- package/dist/lib/editor/project-watches.js +86 -0
- package/dist/lib/editor/release-vsix.js +23 -1
- package/dist/lib/editor/reliability-examples.js +36 -0
- package/dist/lib/editor/scan-session.js +212 -62
- package/dist/lib/editor/security-examples.js +24 -14
- package/dist/lib/editor/server-commands.js +24 -11
- package/dist/lib/editor/setup.js +7 -12
- package/dist/lib/editor/standalone-performance-examples.js +51 -0
- package/dist/lib/editor/workspace-files.js +32 -8
- package/dist/lib/editor/workspace-paths.js +29 -7
- package/dist/lib/editor/zed-settings.js +118 -0
- package/dist/lib/editor/zed-setup.js +88 -0
- package/dist/lib/maintainability/analysis/analyze-source.js +8 -3
- package/dist/lib/maintainability/analysis/source-exclusions.js +2 -1
- package/dist/lib/maintainability/analysis/source-facts.js +2 -2
- package/dist/lib/maintainability/architecture/architecture.js +50 -2
- package/dist/lib/maintainability/architecture/graph.js +2 -1
- package/dist/lib/maintainability/architecture/layout.js +2 -1
- package/dist/lib/maintainability/cli/apply-fix.js +32 -7
- package/dist/lib/maintainability/cli/changed-lines.js +7 -113
- package/dist/lib/maintainability/cli/finding-ids.js +3 -6
- package/dist/lib/maintainability/cli/fix-cli.js +1 -9
- package/dist/lib/maintainability/cli/git-inventory.js +5 -6
- package/dist/lib/maintainability/cli/inputs.js +24 -16
- package/dist/lib/maintainability/cli/scan-arguments.js +33 -0
- package/dist/lib/maintainability/cli/site-fix.js +31 -13
- package/dist/lib/maintainability/cli.js +31 -38
- package/dist/lib/maintainability/entry-points/entry-points.js +27 -68
- package/dist/lib/maintainability/examples.js +60 -0
- package/dist/lib/maintainability/polyglot-duplicates.js +1 -0
- package/dist/lib/maintainability/polyglot.js +337 -12
- package/dist/lib/maintainability/project.js +4 -4
- package/dist/lib/maintainability/quality/console-tooling.js +114 -0
- package/dist/lib/maintainability/quality/declarative-imports.js +18 -0
- package/dist/lib/maintainability/quality/deprecated-apis.js +227 -40
- package/dist/lib/maintainability/quality/duplicates.js +5 -11
- package/dist/lib/maintainability/quality/generic-assertion-target.js +75 -0
- package/dist/lib/maintainability/quality/limits.js +5 -1
- package/dist/lib/maintainability/quality/modern-node-callbacks.js +188 -0
- package/dist/lib/maintainability/quality/modern-syntax.js +301 -0
- package/dist/lib/maintainability/quality/size-limits.js +2 -1
- package/dist/lib/maintainability/quality/stray-console.js +31 -7
- package/dist/lib/maintainability/quality/tsconfig-strict.js +432 -21
- package/dist/lib/maintainability/quality/type-escape-hatches.js +411 -0
- package/dist/lib/maintainability/quality/type-safety-hygiene.js +132 -42
- package/dist/lib/maintainability/quality/unowned-source.js +15 -0
- package/dist/lib/maintainability/rule-ids.js +27 -0
- package/dist/lib/maintainability/scan-changed.js +39 -3
- package/dist/lib/maintainability/scan-worker.js +3 -5
- package/dist/lib/maintainability/scan.js +26 -4
- package/dist/lib/maintainability/site-fixes/duplicate-edits.js +3 -2
- package/dist/lib/maintainability/site-fixes/duplicate-methods.js +7 -2
- package/dist/lib/maintainability/site-fixes/duplicates.js +3 -2
- package/dist/lib/maintainability/site-fixes/focused-test.js +230 -0
- package/dist/lib/maintainability/site-fixes/helpers.js +2 -6
- package/dist/lib/maintainability/site-fixes/if-rewrites.js +1 -7
- package/dist/lib/maintainability/site-fixes/large-module.js +2 -1
- package/dist/lib/maintainability/site-fixes/unused-bindings.js +15 -6
- package/dist/lib/maintainability/unused/ancestor-aliases.js +2 -2
- package/dist/lib/maintainability/unused/module-usage-dynamic.js +2 -1
- package/dist/lib/maintainability/unused/module-usage-named-exports.js +125 -0
- package/dist/lib/maintainability/unused/module-usage-signatures.js +116 -0
- package/dist/lib/maintainability/unused/module-usage.js +75 -109
- package/dist/lib/maintainability/unused/unused-bindings.js +143 -8
- package/dist/lib/maintainability/unused/unused-dependencies.js +218 -0
- package/dist/lib/maintainability/unused/unused-modules.js +39 -1
- package/dist/lib/performance/analysis/call-syntax.js +2 -1
- package/dist/lib/performance/analysis/function-kinds.js +1 -5
- package/dist/lib/performance/analysis/missing-packages.js +13 -7
- package/dist/lib/performance/analysis/package-types.js +10 -2
- package/dist/lib/performance/analysis/schema-tooling.js +157 -8
- package/dist/lib/performance/analysis/source-inputs.js +17 -12
- package/dist/lib/performance/analysis/source-text.js +2 -2
- package/dist/lib/performance/analysis/unscanned-javascript.js +6 -5
- package/dist/lib/performance/analyze.js +25 -6
- package/dist/lib/performance/async/async-errors.js +162 -14
- package/dist/lib/performance/async/await-before-early-exit.js +1 -6
- package/dist/lib/performance/async/floating-promises.js +27 -6
- package/dist/lib/performance/async/promise-return-escapes-catch.js +35 -2
- package/dist/lib/performance/async/stream-errors.js +1 -3
- package/dist/lib/performance/cli/changed-lines.js +14 -111
- package/dist/lib/performance/cli/cli-arguments.js +11 -9
- package/dist/lib/performance/cli/cli-markup.js +42 -0
- package/dist/lib/performance/cli/cli-output.js +9 -3
- package/dist/lib/performance/cli/cli-policy.js +174 -17
- package/dist/lib/performance/cli/cli-scan.js +170 -139
- package/dist/lib/performance/cli/finding-ids.js +7 -7
- package/dist/lib/performance/cli/fix-cli.js +83 -34
- package/dist/lib/performance/cli/prisma-schema-findings.js +23 -0
- package/dist/lib/performance/cli/scan-outcome.js +19 -1
- package/dist/lib/performance/cli/shared-security-inputs.js +27 -0
- package/dist/lib/performance/cli/watch-security.js +33 -0
- package/dist/lib/performance/cli/watch.js +42 -15
- package/dist/lib/performance/cli.js +8 -7
- package/dist/lib/performance/collections/array-drains.js +354 -0
- package/dist/lib/performance/collections/collection-bindings.js +1 -2
- package/dist/lib/performance/collections/collection-bounds.js +3 -2
- package/dist/lib/performance/collections/collection-copy.js +51 -1
- package/dist/lib/performance/collections/collection-lookups.js +74 -13
- package/dist/lib/performance/collections/collection-reduce.js +32 -6
- package/dist/lib/performance/collections/collections.js +34 -2
- package/dist/lib/performance/collections/json-clone.js +137 -17
- package/dist/lib/performance/collections/regex-allocation.js +156 -0
- package/dist/lib/performance/collections/repeated.js +26 -8
- package/dist/lib/performance/collections/sort-extreme.js +18 -1
- package/dist/lib/performance/collections/workbook-decodes.js +3 -2
- package/dist/lib/performance/contracts/cli.js +340 -21
- package/dist/lib/performance/contracts/git-files.js +102 -5
- package/dist/lib/performance/contracts/openapi-schema.js +187 -0
- package/dist/lib/performance/contracts/openapi-sources.js +260 -0
- package/dist/lib/performance/contracts/openapi.js +172 -233
- package/dist/lib/performance/contracts/protobuf.js +301 -0
- package/dist/lib/performance/contracts/trpc-moves.js +46 -0
- package/dist/lib/performance/contracts/trpc.js +477 -0
- package/dist/lib/performance/datastores/pg-integrity.js +2 -1
- package/dist/lib/performance/datastores/pooling.js +3 -18
- package/dist/lib/performance/datastores/postgres.js +41 -33
- package/dist/lib/performance/datastores/redis-keys.js +4 -3
- package/dist/lib/performance/datastores/redis.js +8 -1
- package/dist/lib/performance/datastores/repeated-reads.js +104 -0
- package/dist/lib/performance/datastores/search-clients.js +9 -0
- package/dist/lib/performance/datastores/session-store.js +166 -7
- package/dist/lib/performance/datastores/supabase.js +73 -0
- package/dist/lib/performance/db/checks.js +1 -1
- package/dist/lib/performance/db/cli-mysql.js +12 -2
- package/dist/lib/performance/db/cli.js +38 -5
- package/dist/lib/performance/db/drivers.js +20 -4
- package/dist/lib/performance/db/measure.js +1 -1
- package/dist/lib/performance/db/mysql-catalog.js +1 -1
- package/dist/lib/performance/db/plan-estimates.js +46 -7
- package/dist/lib/performance/db/redact.js +1 -3
- package/dist/lib/performance/db/snapshot.js +1 -1
- package/dist/lib/performance/db/sqlite-plan.js +95 -0
- package/dist/lib/performance/engine/compiler.js +3 -2
- package/dist/lib/performance/engine/native-checker.js +85 -10
- package/dist/lib/performance/engine/native-syntax.js +17 -0
- package/dist/lib/performance/engine/native-workspaces.js +36 -8
- package/dist/lib/performance/engine/native.js +42 -16
- package/dist/lib/performance/engine/review-config-inputs.js +57 -0
- package/dist/lib/performance/evidence/plans.js +14 -16
- package/dist/lib/performance/evidence/trace-formats.js +182 -0
- package/dist/lib/performance/evidence/traces.js +6 -6
- package/dist/lib/performance/frontend/angular-bootstrap.js +309 -0
- package/dist/lib/performance/frontend/angular-template-calls.js +187 -0
- package/dist/lib/performance/frontend/barrel-subpaths.js +204 -0
- package/dist/lib/performance/frontend/effect-cleanup.js +30 -4
- package/dist/lib/performance/frontend/frontend-dom-perf.js +79 -15
- package/dist/lib/performance/frontend/frontend-perf.js +119 -176
- package/dist/lib/performance/frontend/frontend-render-perf.js +17 -13
- package/dist/lib/performance/frontend/jsx-element-perf.js +171 -0
- package/dist/lib/performance/frontend/layout-binary-probe.js +186 -0
- package/dist/lib/performance/frontend/next-fetch-waterfall.js +405 -0
- package/dist/lib/performance/frontend/rxjs-subscriptions.js +155 -0
- package/dist/lib/performance/frontend/seo/client-fetched-content.js +196 -0
- package/dist/lib/performance/frontend/seo/navigation-without-link.js +116 -0
- package/dist/lib/performance/frontend/seo/next-routes.js +114 -0
- package/dist/lib/performance/frontend/seo/route-metadata.js +158 -0
- package/dist/lib/performance/frontend/seo/seo-rules.js +9 -0
- package/dist/lib/performance/frontend/seo/sitewide-noindex.js +103 -0
- package/dist/lib/performance/frontend/template-tracking.js +215 -0
- package/dist/lib/performance/frontend/vue-options-hooks.js +108 -0
- package/dist/lib/performance/index-rules/index-rules-table.js +3 -3
- package/dist/lib/performance/index-rules/redundant-indexes.js +6 -13
- package/dist/lib/performance/migrations/cli.js +65 -14
- package/dist/lib/performance/migrations/discover.js +63 -32
- package/dist/lib/performance/migrations/enforce.js +5 -12
- package/dist/lib/performance/migrations/extract-code-sql.js +10 -7
- package/dist/lib/performance/migrations/extract-code.js +1 -0
- package/dist/lib/performance/migrations/extract-sql.js +45 -4
- package/dist/lib/performance/migrations/extract-sqlite.js +302 -0
- package/dist/lib/performance/migrations/operations.js +122 -8
- package/dist/lib/performance/migrations/postgres-registry.js +6 -6
- package/dist/lib/performance/migrations/postgres-table-history.js +147 -0
- package/dist/lib/performance/migrations/rules-postgres-shared.js +4 -6
- package/dist/lib/performance/migrations/rules-postgres.js +67 -13
- package/dist/lib/performance/migrations/rules-sqlite.js +118 -0
- package/dist/lib/performance/migrations/sqlserver-creation.js +131 -0
- package/dist/lib/performance/migrations/sqlserver.js +81 -0
- package/dist/lib/performance/models/client-imports.js +286 -0
- package/dist/lib/performance/models/index.js +46 -8
- package/dist/lib/performance/orm/cartesian-includes.js +49 -22
- package/dist/lib/performance/orm/drizzle.js +86 -27
- package/dist/lib/performance/orm/knex-loop-operations.js +96 -0
- package/dist/lib/performance/orm/orm-owners.js +3 -5
- package/dist/lib/performance/orm/orm-queries.js +50 -152
- package/dist/lib/performance/orm/orm-result-uses.js +116 -0
- package/dist/lib/performance/orm/prisma-integrity.js +24 -3
- package/dist/lib/performance/orm/prisma.js +32 -33
- package/dist/lib/performance/orm/typeorm-batch-filter.js +43 -0
- package/dist/lib/performance/orm/typeorm-projection.js +2 -2
- package/dist/lib/performance/orm/typeorm-transaction-loops.js +3 -4
- package/dist/lib/performance/orm/typeorm-updates.js +1 -3
- package/dist/lib/performance/orm/unbounded-list-page-size.js +179 -0
- package/dist/lib/performance/orm/unbounded-list-queries.js +63 -146
- package/dist/lib/performance/polyglot.js +173 -61
- package/dist/lib/performance/probe-caches.js +42 -0
- package/dist/lib/performance/program-batches.js +138 -0
- package/dist/lib/performance/projects.js +86 -89
- package/dist/lib/performance/query-loops/guard-queries.js +2 -1
- package/dist/lib/performance/query-loops/parallel-reads-policy.js +1 -3
- package/dist/lib/performance/query-loops/query-loop-batch.js +81 -7
- package/dist/lib/performance/query-loops/query-loop-bounds.js +1 -13
- package/dist/lib/performance/query-loops/query-policy.js +19 -20
- package/dist/lib/performance/query-loops/query-results.js +1 -6
- package/dist/lib/performance/query-loops/query-write-context.js +89 -0
- package/dist/lib/performance/query-loops/sequential-loops.js +6 -24
- package/dist/lib/performance/query-loops/service-call-resolution.js +17 -2
- package/dist/lib/performance/query-loops/service-loop-source.js +124 -0
- package/dist/lib/performance/query-loops/service-loops.js +86 -25
- package/dist/lib/performance/query-loops/throw-on-miss-loops.js +141 -0
- package/dist/lib/performance/request/backend-mastery.js +18 -30
- package/dist/lib/performance/request/fixed-emitter-loop.js +98 -0
- package/dist/lib/performance/request/fresh-mapped-elements.js +137 -0
- package/dist/lib/performance/request/graphql-list-lookups.js +258 -0
- package/dist/lib/performance/request/http-options-writes.js +2 -8
- package/dist/lib/performance/request/http-timeouts.js +3 -2
- package/dist/lib/performance/request/json-stringify-output.js +217 -0
- package/dist/lib/performance/request/llm-max-tokens.js +27 -8
- package/dist/lib/performance/request/mongoose-lean.js +15 -10
- package/dist/lib/performance/request/node-event-listener-leak.js +190 -35
- package/dist/lib/performance/request/node-fs-context.js +6 -8
- package/dist/lib/performance/request/node-fs.js +4 -6
- package/dist/lib/performance/request/password-hashing.js +4 -3
- package/dist/lib/performance/request/phase5-ast.js +3 -9
- package/dist/lib/performance/request/phase5-rules.js +50 -102
- package/dist/lib/performance/request/promise-schedulers.js +180 -0
- package/dist/lib/performance/request/pure-js-hashing.js +2 -1
- package/dist/lib/performance/request/request-handlers.js +44 -7
- package/dist/lib/performance/request/request-inputs.js +121 -26
- package/dist/lib/performance/request/unbounded-promise-all.js +142 -52
- package/dist/lib/performance/rule-ids.js +72 -5
- package/dist/lib/performance/schema/context.js +7 -16
- package/dist/lib/performance/schema/model.js +1 -9
- package/dist/lib/performance/schema/prisma-owners.js +15 -1
- package/dist/lib/performance/schema/prisma-schema.js +5 -6
- package/dist/lib/performance/schema/project-indexes-events.js +8 -2
- package/dist/lib/performance/schema/project-indexes.js +4 -2
- package/dist/lib/performance/schema/query-site-support.js +1 -1
- package/dist/lib/performance/schema/sequelize-schema.js +1 -3
- package/dist/lib/performance/schema/ts-helpers.js +3 -7
- package/dist/lib/performance/shared-libs.js +48 -0
- package/dist/lib/performance/site-fix.js +33 -7
- package/dist/lib/performance/site-fixes/collection-copy.js +2 -1
- package/dist/lib/performance/site-fixes/collection-existence.js +2 -1
- package/dist/lib/performance/site-fixes/collection-find.js +2 -1
- package/dist/lib/performance/site-fixes/collection-helpers.js +0 -6
- package/dist/lib/performance/site-fixes/collection-lookups.js +2 -1
- package/dist/lib/performance/site-fixes/database.js +7 -16
- package/dist/lib/performance/site-fixes/drizzle-index.js +2 -9
- package/dist/lib/performance/site-fixes/frontend-fixes.js +47 -15
- package/dist/lib/performance/site-fixes/helpers.js +19 -18
- package/dist/lib/performance/site-fixes/last-insert-id.js +2 -1
- package/dist/lib/performance/site-fixes/llm-max-tokens.js +56 -0
- package/dist/lib/performance/site-fixes/migration-column-rules.js +11 -7
- package/dist/lib/performance/site-fixes/migration-lock-rules.js +6 -3
- package/dist/lib/performance/site-fixes/migrations.js +4 -0
- package/dist/lib/performance/site-fixes/pure-js-hashing.js +2 -2
- package/dist/lib/performance/site-fixes/query-shapes.js +1 -4
- package/dist/lib/performance/site-fixes/service-loop-ast.js +1 -9
- package/dist/lib/performance/site-fixes/small-rewrites.js +28 -2
- package/dist/lib/performance/site-fixes/template-tracking-fixes.js +82 -0
- package/dist/lib/performance/site-fixes/writes.js +1 -6
- package/dist/lib/performance/sql/local-statements.js +108 -0
- package/dist/lib/performance/sql/mysql-tokens.js +1 -4
- package/dist/lib/performance/sql/pg-parser.js +3 -5
- package/dist/lib/performance/sql/sqlserver-control.js +43 -0
- package/dist/lib/reliability/analyze.js +48 -5
- package/dist/lib/reliability/boundary-access.js +34 -27
- package/dist/lib/reliability/callback-completion.js +10 -2
- package/dist/lib/reliability/child-process.js +2 -2
- package/dist/lib/reliability/crlf-line-split.js +124 -73
- package/dist/lib/reliability/crlf-references.js +78 -0
- package/dist/lib/reliability/default-numeric-sort.js +25 -0
- package/dist/lib/reliability/error-cause-plan.js +29 -0
- package/dist/lib/reliability/error-values.js +68 -27
- package/dist/lib/reliability/json-cast.js +368 -0
- package/dist/lib/reliability/key-test-callee.js +50 -0
- package/dist/lib/reliability/lossy-text-rewrite.js +94 -0
- package/dist/lib/reliability/manifest-boundary.js +466 -0
- package/dist/lib/reliability/manifest-snapshot.js +40 -0
- package/dist/lib/reliability/parse-failure-flow.js +5 -2
- package/dist/lib/reliability/parse-failure-paths.js +39 -8
- package/dist/lib/reliability/parse-failure-reset.js +5 -17
- package/dist/lib/reliability/pool-timeout.js +31 -7
- package/dist/lib/reliability/promise-usage.js +281 -0
- package/dist/lib/reliability/react-bugs.js +16 -6
- package/dist/lib/reliability/react-state-aliases.js +94 -4
- package/dist/lib/reliability/react-state-order.js +2 -2
- package/dist/lib/reliability/react-state-paths.js +2 -2
- package/dist/lib/reliability/react-state-setter.js +5 -11
- package/dist/lib/reliability/react-state-walker.js +3 -3
- package/dist/lib/reliability/react-state.js +24 -5
- package/dist/lib/reliability/required-member.js +19 -0
- package/dist/lib/reliability/resource-leak-intervals.js +4 -7
- package/dist/lib/reliability/resource-leaks.js +4 -7
- package/dist/lib/reliability/rule-ids.js +70 -1
- package/dist/lib/reliability/same-file-io.js +135 -0
- package/dist/lib/reliability/short-write.js +220 -0
- package/dist/lib/reliability/site-fixes/crlf-line-split.js +71 -0
- package/dist/lib/reliability/site-fixes/error-values.js +40 -0
- package/dist/lib/reliability/site-fixes/pool-timeout.js +51 -0
- package/dist/lib/reliability/source-helpers.js +18 -8
- package/dist/lib/reliability/standalone-sources.js +8 -6
- package/dist/lib/reliability/suspicious-logic.js +6 -8
- package/dist/lib/reliability/swallowed-errors.js +3 -7
- package/dist/lib/reliability/switch-exhaustive.js +195 -5
- package/dist/lib/reliability/test-cleanup-after-await.js +2 -2
- package/dist/lib/reliability/throw-string-plan.js +121 -0
- package/dist/lib/reliability/uncaught-exception.js +2 -7
- package/dist/lib/reliability/usage.js +1 -1
- package/dist/lib/reliability/working-directory.js +101 -0
- package/dist/lib/security/analyze.js +2 -0
- package/dist/lib/security/auth-crypto/hashing.js +21 -4
- package/dist/lib/security/auth-crypto/index.js +6 -1
- package/dist/lib/security/auth-crypto/jwt-decode-helpers.js +163 -0
- package/dist/lib/security/auth-crypto/jwt.js +52 -36
- package/dist/lib/security/auth-crypto/plaintext-password.js +2 -1
- package/dist/lib/security/auth-crypto/random.js +2 -1
- package/dist/lib/security/auth-crypto/rate-limits.js +79 -8
- package/dist/lib/security/auth-crypto/rule-ids.js +2 -0
- package/dist/lib/security/auth-crypto/secrets.js +132 -19
- package/dist/lib/security/auth-crypto/shared.js +1 -4
- package/dist/lib/security/auth-crypto/signature-verification.js +29 -0
- package/dist/lib/security/auth-crypto/transport-and-ciphers.js +43 -3
- package/dist/lib/security/auth-crypto/weak-hash.js +183 -0
- package/dist/lib/security/bindings.js +41 -9
- package/dist/lib/security/cli.js +84 -27
- package/dist/lib/security/cookie-csrf.js +316 -7
- package/dist/lib/security/credential-entropy.js +12 -0
- package/dist/lib/security/deps/cargo-lock.js +78 -0
- package/dist/lib/security/deps/cli.js +4 -4
- package/dist/lib/security/deps/fixed-version.js +2 -2
- package/dist/lib/security/deps/lockfiles.js +207 -17
- package/dist/lib/security/deps/osv.js +190 -59
- package/dist/lib/security/deps/scan.js +87 -19
- package/dist/lib/security/examples/{auth-crypto.cjs → auth-crypto.js} +11 -5
- package/dist/lib/security/examples/{deps.cjs → deps.js} +1 -3
- package/dist/lib/security/examples/{exposure.cjs → exposure.js} +17 -3
- package/dist/lib/security/examples/files.js +146 -0
- package/dist/lib/security/examples/{injection.cjs → injection.js} +13 -3
- package/dist/lib/security/examples/{moved.cjs → moved.js} +1 -3
- package/dist/lib/security/examples/{request-forgery.cjs → request-forgery.js} +2 -4
- package/dist/lib/security/exposure/backend-security-mastery.js +2 -1
- package/dist/lib/security/exposure/client-env.js +2 -1
- package/dist/lib/security/exposure/content-disposition.js +71 -0
- package/dist/lib/security/exposure/cookies.js +200 -1
- package/dist/lib/security/exposure/cors.js +63 -4
- package/dist/lib/security/exposure/frontend-security.js +18 -62
- package/dist/lib/security/exposure/index.js +9 -0
- package/dist/lib/security/exposure/js-yaml.js +203 -0
- package/dist/lib/security/exposure/message-effects.js +266 -0
- package/dist/lib/security/exposure/package-manifest.js +2 -2
- package/dist/lib/security/exposure/prototype-pollution.js +99 -5
- package/dist/lib/security/exposure/reflected-xss.js +47 -12
- package/dist/lib/security/exposure/response-content-type.js +181 -0
- package/dist/lib/security/exposure/rule-ids.js +4 -0
- package/dist/lib/security/exposure/trust-boundary.js +142 -0
- package/dist/lib/security/exposure/url-secrets.js +38 -2
- package/dist/lib/security/exposure/webhook-verification.js +231 -0
- package/dist/lib/security/express-registration.js +45 -0
- package/dist/lib/security/express-router-factories.js +118 -0
- package/dist/lib/security/files/azure-pipelines.js +69 -0
- package/dist/lib/security/files/bitbucket-pipelines.js +32 -0
- package/dist/lib/security/files/ci-platforms.js +16 -0
- package/dist/lib/security/files/ci-shared.js +260 -0
- package/dist/lib/security/files/circleci.js +81 -0
- package/dist/lib/security/files/component-markup.js +66 -0
- package/dist/lib/security/files/compose.js +2 -1
- package/dist/lib/security/files/dockerfile.js +188 -3
- package/dist/lib/security/files/github-actions.js +490 -0
- package/dist/lib/security/files/gitlab-ci.js +90 -0
- package/dist/lib/security/files/hcl.js +264 -0
- package/dist/lib/security/files/hosting-config.js +159 -0
- package/dist/lib/security/files/http-headers.js +65 -0
- package/dist/lib/security/files/index.js +182 -33
- package/dist/lib/security/files/jenkinsfile.js +482 -0
- package/dist/lib/security/files/json-nodes.js +67 -0
- package/dist/lib/security/files/kubernetes.js +136 -0
- package/dist/lib/security/files/nginx.js +501 -0
- package/dist/lib/security/files/package-scripts.js +175 -0
- package/dist/lib/security/files/project-files.js +98 -31
- package/dist/lib/security/files/rule-ids.js +31 -0
- package/dist/lib/security/files/secret-values.js +31 -5
- package/dist/lib/security/files/secrets.js +53 -18
- package/dist/lib/security/files/terraform.js +345 -0
- package/dist/lib/security/injection/code.js +33 -5
- package/dist/lib/security/injection/command.js +51 -4
- package/dist/lib/security/injection/escape-preserving.js +219 -0
- package/dist/lib/security/injection/escape-replace.js +174 -2
- package/dist/lib/security/injection/index.js +5 -1
- package/dist/lib/security/injection/nosql.js +3 -2
- package/dist/lib/security/injection/redos.js +25 -4
- package/dist/lib/security/injection/rule-ids.js +3 -0
- package/dist/lib/security/injection/shell-output-guard.js +97 -0
- package/dist/lib/security/injection/sql.js +53 -2
- package/dist/lib/security/injection/xpath.js +35 -0
- package/dist/lib/security/lexical-declaration.js +28 -0
- package/dist/lib/security/pg-identifier-guards.js +146 -5
- package/dist/lib/security/phase5-rules.js +1 -0
- package/dist/lib/security/polyglot.js +35 -3
- package/dist/lib/security/provider-credentials.js +29 -0
- package/dist/lib/security/redirect-settings.js +131 -6
- package/dist/lib/security/request-forgery/contained-helper.js +75 -0
- package/dist/lib/security/request-forgery/member-chain.js +41 -0
- package/dist/lib/security/request-forgery/open-redirect-query.js +2 -1
- package/dist/lib/security/request-forgery/open-redirect.js +69 -9
- package/dist/lib/security/request-forgery/parsed-host-guard.js +213 -0
- package/dist/lib/security/request-forgery/path-traversal.js +36 -1
- package/dist/lib/security/request-forgery/shared.js +205 -30
- package/dist/lib/security/request-forgery/ssrf.js +145 -1
- package/dist/lib/security/rule-descriptions.js +46 -1
- package/dist/lib/security/rule-ids.js +50 -0
- package/dist/lib/security/scope/drizzle-policy.js +2 -1
- package/dist/lib/security/scope/kysely-policy.js +173 -0
- package/dist/lib/security/site-fixes/auth-crypto.js +3 -1
- package/dist/lib/security/taint/accessors.js +364 -0
- package/dist/lib/security/taint/array-writes.js +139 -0
- package/dist/lib/security/taint/binding-inputs.js +4 -3
- package/dist/lib/security/taint/field-access.js +80 -0
- package/dist/lib/security/taint/filename-guard.js +81 -6
- package/dist/lib/security/taint/guards.js +150 -17
- package/dist/lib/security/taint/index.js +41 -116
- package/dist/lib/security/taint/original-string-validation.js +229 -0
- package/dist/lib/security/taint/propagate.js +5 -6
- package/dist/lib/security/taint/resolution-cache.js +10 -1
- package/dist/lib/security/taint/sanitizers.js +5 -5
- package/dist/lib/security/taint/shape-flows.js +128 -0
- package/dist/lib/security/taint/sink-alphabets.js +237 -0
- package/dist/lib/security/taint/sources.js +151 -8
- package/dist/lib/security/taint/trace-nodes.js +35 -2
- package/dist/lib/security/taint/validators.js +59 -20
- package/dist/lib/security/trusted-bindings.js +44 -0
- package/dist/lib/shared/agent/agent-init.js +84 -9
- package/dist/lib/shared/agent/agent-integrations.js +626 -0
- package/dist/lib/shared/agent/agent-prompt.js +2 -1
- package/dist/lib/shared/agent/agent-session.js +1 -1
- package/dist/lib/shared/agent/agent-toml.js +98 -0
- package/dist/lib/shared/agent/agent-verify.js +21 -3
- package/dist/lib/shared/agent/git-hook.js +31 -4
- package/dist/lib/shared/agent/notify-editor.js +2 -1
- package/dist/lib/shared/agent/review-delivery.js +3 -1
- package/dist/lib/shared/agent/review-mcp.js +67 -13
- package/dist/lib/shared/agent/review-request.js +4 -0
- package/dist/lib/shared/analysis/ast-helpers.js +50 -0
- package/dist/lib/shared/analysis/ast-semantics.js +23 -1
- package/dist/lib/shared/analysis/binding-names.js +13 -0
- package/dist/lib/shared/analysis/execution-context.js +49 -9
- package/dist/lib/shared/analysis/hot-path-graph.js +55 -19
- package/dist/lib/shared/analysis/next-env-config.js +232 -0
- package/dist/lib/shared/analysis/polyglot-compatibility.js +102 -23
- package/dist/lib/shared/analysis/scan-cache-git.js +114 -0
- package/dist/lib/shared/analysis/scan-cache-loadwise-packages.js +54 -0
- package/dist/lib/shared/analysis/scan-cache-project-inputs.js +221 -0
- package/dist/lib/shared/analysis/scan-cache-sources.js +235 -0
- package/dist/lib/shared/analysis/scan-cache-storage.js +204 -0
- package/dist/lib/shared/analysis/scan-cache.js +373 -166
- package/dist/lib/shared/analysis/valid-javascript.js +118 -0
- package/dist/lib/shared/changed-lines.js +129 -0
- package/dist/lib/shared/check-options.js +63 -0
- package/dist/lib/shared/check-watch-inputs.js +152 -0
- package/dist/lib/shared/check-watch-process.js +57 -0
- package/dist/lib/shared/check-watch.js +136 -0
- package/dist/lib/shared/check.js +97 -40
- package/dist/lib/shared/completion-shells.js +127 -0
- package/dist/lib/shared/completion.js +124 -0
- package/dist/lib/shared/config-rule-validation.js +135 -0
- package/dist/lib/shared/config.js +330 -163
- package/dist/lib/shared/conventional-projects.js +40 -0
- package/dist/lib/shared/declarative-rule-packs.js +173 -0
- package/dist/lib/shared/explain.js +47 -9
- package/dist/lib/shared/fix/fix-command.js +2 -0
- package/dist/lib/shared/fix/fix-convergence.js +45 -128
- package/dist/lib/shared/fix/fix-history.js +130 -26
- package/dist/lib/shared/fix/fix-interactive.js +78 -0
- package/dist/lib/shared/fix/fix-patch.js +89 -0
- package/dist/lib/shared/fix/fix-polyglot-preview.js +166 -0
- package/dist/lib/shared/fix/fix-presentation-biome.js +120 -0
- package/dist/lib/shared/fix/fix-presentation-prettier.js +27 -10
- package/dist/lib/shared/fix/fix-presentation-rows.js +5 -1
- package/dist/lib/shared/fix/fix-presentation.js +22 -15
- package/dist/lib/shared/fix/fix-project-membership.js +79 -0
- package/dist/lib/shared/fix/fix-reversal-proof.js +107 -0
- package/dist/lib/shared/fix/fix-reverse.js +37 -0
- package/dist/lib/shared/fix/fix-safety.js +4 -4
- package/dist/lib/shared/fix/fix-scope.js +13 -9
- package/dist/lib/shared/fix/fix-source-snapshot.js +92 -0
- package/dist/lib/shared/fix/fix-staging.js +129 -0
- package/dist/lib/shared/fix/fix-terminal.js +34 -9
- package/dist/lib/shared/fix/fix-typecheck.js +21 -8
- package/dist/lib/shared/fix/fix-usage.js +47 -0
- package/dist/lib/shared/fix/project-file-access.js +85 -29
- package/dist/lib/shared/fix/read-fix-text.js +23 -0
- package/dist/lib/shared/fix/reversal-lock.js +37 -0
- package/dist/lib/shared/fix/review-fix-mode.js +9 -0
- package/dist/lib/shared/fix.js +157 -52
- package/dist/lib/shared/formats/ci-consumers.js +84 -0
- package/dist/lib/shared/formats/finding-location.js +52 -3
- package/dist/lib/shared/formats/github.js +22 -7
- package/dist/lib/shared/formats/index.js +21 -5
- package/dist/lib/shared/formats/readable.js +63 -0
- package/dist/lib/shared/formats/report-rows.js +38 -0
- package/dist/lib/shared/formats/sarif-fixes.js +261 -0
- package/dist/lib/shared/formats/sarif.js +175 -33
- package/dist/lib/shared/formats/security-cwe.js +142 -0
- package/dist/lib/shared/node-scan.js +64 -0
- package/dist/lib/shared/package-root.js +2 -0
- package/dist/lib/shared/project-root.js +27 -1
- package/dist/lib/shared/reporting/action-comparison.js +78 -0
- package/dist/lib/shared/reporting/action-summary.js +31 -0
- package/dist/lib/shared/reporting/automatic-fix-signal.js +7 -2
- package/dist/lib/shared/reporting/baseline.js +12 -12
- package/dist/lib/shared/reporting/check-text.js +7 -5
- package/dist/lib/shared/reporting/finding-id-hash.js +7 -0
- package/dist/lib/shared/reporting/impact-levels.js +1 -1
- package/dist/lib/shared/reporting/pillar-rules.js +13 -1
- package/dist/lib/shared/reporting/pillars.js +61 -23
- package/dist/lib/shared/reporting/rule-docs.js +2 -2
- package/dist/lib/shared/reporting/rule-pack-fingerprint.js +21 -0
- package/dist/lib/shared/reporting/source-report.js +20 -6
- package/dist/lib/shared/reporting/stray-console-methods.js +1 -0
- package/dist/lib/shared/rule-registry.js +6 -1
- package/dist/lib/shared/system/atomic-write.js +12 -6
- package/dist/lib/shared/system/component-source.js +28 -0
- package/dist/lib/shared/system/environment.js +12 -0
- package/dist/lib/shared/system/file-key.js +8 -0
- package/dist/lib/shared/system/git.js +62 -0
- package/dist/lib/shared/system/glob.js +233 -28
- package/dist/lib/shared/system/jsonc-config.js +63 -0
- package/dist/lib/shared/system/path-inside.js +19 -0
- package/dist/lib/shared/system/posix-path.js +22 -0
- package/dist/lib/shared/system/read-json.js +10 -0
- package/dist/lib/shared/system/sentry.js +6 -3
- package/dist/lib/shared/system/terminal-style.js +2 -2
- package/dist/lib/shared/system/text-helpers.js +40 -0
- package/dist/lib/shared/system/windows-orphans-script.js +75 -0
- package/dist/lib/shared/system/windows-orphans.js +28 -0
- package/dist/lib/shared/types/changed-lines.js +1 -0
- package/dist/lib/shared/types/completion.js +1 -0
- package/dist/lib/shared/workspace-selection.js +67 -0
- package/dist/lib/shared/workspaces.js +215 -68
- package/dist/polyglot/maintainability/rules.js +119 -3
- package/examples/README.md +45 -0
- package/examples/clean/avatar.html +1 -0
- package/examples/clean/source.ts +10 -0
- package/examples/clean/tsconfig.json +4 -0
- package/examples/findings/avatar.html +1 -0
- package/examples/findings/source.ts +11 -0
- package/examples/findings/tsconfig.json +4 -0
- package/examples/labels-clean.py +5 -0
- package/integrations/zed/Cargo.lock +1 -1
- package/integrations/zed/Cargo.toml +1 -1
- package/integrations/zed/LICENSE +201 -0
- package/integrations/zed/extension.toml +3 -3
- package/integrations/zed/extension.wasm +0 -0
- package/integrations/zed/src/lib.rs +108 -8
- package/package.json +28 -14
- package/polyglot/performance/rules/csharp.yml +173 -10
- package/polyglot/performance/rules/go.yml +15 -7
- package/polyglot/performance/rules/input.yml +12 -0
- package/polyglot/performance/rules/java.yml +52 -1
- package/polyglot/performance/rules/php.yml +146 -0
- package/polyglot/performance/rules/python.yml +7 -3
- package/polyglot/performance/rules/ruby.yml +81 -0
- package/polyglot/performance/sgconfig.yml +2 -0
- package/polyglot/reliability/rules/csharp.yml +105 -0
- package/polyglot/reliability/rules/go.yml +339 -0
- package/polyglot/reliability/rules/input.yml +6 -0
- package/polyglot/reliability/rules/java.yml +218 -0
- package/polyglot/reliability/rules/kotlin.yml +49 -0
- package/polyglot/reliability/rules/python.yml +288 -0
- package/polyglot/reliability/rules/rust.yml +83 -0
- package/polyglot/reliability/sgconfig.yml +1 -0
- package/polyglot/security/rules/csharp.yml +143 -3
- package/polyglot/security/rules/go.yml +59 -4
- package/polyglot/security/rules/java.yml +103 -0
- package/polyglot/security/rules/python.yml +413 -21
- package/polyglot/security/rules/rust.yml +176 -3
- package/polyglot/security/sgconfig.yml +2 -0
- package/polyglot/security/utils/java-imported-jca-cipher.yml +32 -0
- package/polyglot/security/utils/java-unshadowed-javax.yml +29 -0
- package/schema/loadwise.config.schema.json +1137 -600
- package/schema/loadwise.outcomes.schema.json +43 -0
- package/types/scan.d.ts +53 -0
- package/dist/lib/maintainability/site-fixes/exports.js +0 -25
- package/dist/lib/security/examples/files.cjs +0 -30
- package/docs/assets/cli-workflow.gif +0 -0
- package/plugin/.claude-plugin/plugin.json +0 -9
- package/plugin/commands/loadwise.md +0 -29
- package/plugin/hooks/check-edited-file.mjs +0 -173
- package/plugin/hooks/hooks.json +0 -17
- /package/dist/lib/{maintainability/types/changed-lines.js → editor/types/workspace-fix.js} +0 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// Helpers shared by the request-forgery rules: argument and option lookup, response receivers, hop
|
|
2
2
|
// tiering, and the validation evidence that keeps a traced value quiet.
|
|
3
3
|
import { ts } from '../../performance/engine/compiler.js';
|
|
4
|
+
import { isUnshadowedGlobal } from '../../shared/analysis/ast-semantics.js';
|
|
4
5
|
import { importedFrom, stripExpression as strip } from '../bindings.js';
|
|
5
6
|
import { isLiteralList } from '../pg-identifier-guards.js';
|
|
6
7
|
import { isGuardedByCondition, isReassigned } from '../taint/guards.js';
|
|
7
8
|
import { argumentValidations } from '../taint/summaries.js';
|
|
8
9
|
import { isUrlConstructor } from '../taint/url-parts.js';
|
|
10
|
+
import { memberChain, passesChainOwner, samePath } from './member-chain.js';
|
|
9
11
|
const secondHopReason = 'Reached through two calls; confirm the intermediate functions do not validate the value.';
|
|
10
12
|
// Parameter names that hold an HTTP response (Express, Fastify, Koa, Hono) in practice.
|
|
11
13
|
const responseNames = new Set(['res', 'response', 'reply', 'ctx', 'context', 'c']);
|
|
@@ -50,11 +52,6 @@ function isResponseReceiver(expression) {
|
|
|
50
52
|
receiver.expression.kind === ts.SyntaxKind.ThisKeyword &&
|
|
51
53
|
responseNames.has(receiver.name.text));
|
|
52
54
|
}
|
|
53
|
-
// An identifier that is not declared by the project: a global such as `fetch` or `Response`.
|
|
54
|
-
function isGlobalIdentifier(identifier, checker) {
|
|
55
|
-
const declaration = checker.getSymbolAtLocation(identifier)?.declarations?.[0];
|
|
56
|
-
return !declaration || declaration.getSourceFile().isDeclarationFile;
|
|
57
|
-
}
|
|
58
55
|
function isHostHeader(trace) {
|
|
59
56
|
return hostHeaderLabel.test(trace.label);
|
|
60
57
|
}
|
|
@@ -80,8 +77,20 @@ function stableIdentifier(node, sink, checker, properties = false) {
|
|
|
80
77
|
const declaration = symbol?.valueDeclaration;
|
|
81
78
|
if (!symbol || !declaration || !(ts.isParameter(declaration) || constantDeclaration(value, checker)))
|
|
82
79
|
return;
|
|
83
|
-
|
|
80
|
+
const sinkScope = scopeOf(sink);
|
|
81
|
+
const readScope = scopeOf(value);
|
|
82
|
+
const declarationScope = scopeOf(declaration);
|
|
83
|
+
const reassignedAfter = (scope, capture) => ts.isBlock(scope) || ts.isSourceFile(scope)
|
|
84
|
+
? scope.statements.some((statement) => statement.end > capture.getStart() && isReassigned(statement, symbol, checker, properties))
|
|
85
|
+
: isReassigned(scope, symbol, checker, properties);
|
|
86
|
+
if (!isReassigned(sinkScope, symbol, checker, properties) &&
|
|
87
|
+
(readScope === sinkScope ||
|
|
88
|
+
(!reassignedAfter(readScope, value) &&
|
|
89
|
+
(declarationScope === readScope ||
|
|
90
|
+
declarationScope === sinkScope ||
|
|
91
|
+
!reassignedAfter(declarationScope, readScope))))) {
|
|
84
92
|
return value;
|
|
93
|
+
}
|
|
85
94
|
}
|
|
86
95
|
function sameValue(node, reference, checker) {
|
|
87
96
|
const value = strip(node);
|
|
@@ -118,15 +127,32 @@ function isPathSeparator(node, checker) {
|
|
|
118
127
|
value.name.text === 'sep' &&
|
|
119
128
|
importedFrom(strip(value.expression), checker)?.module === 'path');
|
|
120
129
|
}
|
|
121
|
-
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
//
|
|
130
|
+
// A forward slash literal establishes a boundary on POSIX and cannot match native Windows output.
|
|
131
|
+
// A root written only with backslashes, checked against itself plus a backslash, is the Windows
|
|
132
|
+
// boundary; on POSIX the resolved path starts with '/' and never passes it, so the check fails
|
|
133
|
+
// closed. A backslash can be part of a POSIX filename, so a root that mixes both separators is
|
|
134
|
+
// not a boundary. Use the separate path.sep proof for native separators.
|
|
125
135
|
function isRootWithSeparator(prefixText, root) {
|
|
126
|
-
if (!ts.isStringLiteralLike(root)
|
|
136
|
+
if (!ts.isStringLiteralLike(root))
|
|
137
|
+
return false;
|
|
138
|
+
const windowsRoot = root.text.includes('\\');
|
|
139
|
+
if (windowsRoot && root.text.includes('/'))
|
|
127
140
|
return false;
|
|
128
|
-
const
|
|
129
|
-
|
|
141
|
+
const separator = windowsRoot ? '\\' : '/';
|
|
142
|
+
const directory = windowsRoot
|
|
143
|
+
? root.text.replaceAll(/\\+/g, '\\').replace(/\\$/, '')
|
|
144
|
+
: root.text.replaceAll(/\/+/g, '/').replace(/\/$/, '');
|
|
145
|
+
return directory !== '' && prefixText === `${directory}${separator}`;
|
|
146
|
+
}
|
|
147
|
+
// `left + right` or the template `${left}${right}`.
|
|
148
|
+
function prefixOperands(prefix) {
|
|
149
|
+
if (ts.isBinaryExpression(prefix)) {
|
|
150
|
+
return prefix.operatorToken.kind === ts.SyntaxKind.PlusToken ? [prefix.left, prefix.right] : undefined;
|
|
151
|
+
}
|
|
152
|
+
if (!ts.isTemplateExpression(prefix) || prefix.head.text !== '' || prefix.templateSpans.length !== 2)
|
|
153
|
+
return;
|
|
154
|
+
const [first, second] = prefix.templateSpans;
|
|
155
|
+
return first.literal.text === '' && second.literal.text === '' ? [first.expression, second.expression] : undefined;
|
|
130
156
|
}
|
|
131
157
|
// A path starts inside the resolved root only after the directory boundary, or when its relative
|
|
132
158
|
// path is neither an upward traversal nor an absolute path (which can happen across Windows
|
|
@@ -157,19 +183,35 @@ function isContainedPath(sink, expression, context) {
|
|
|
157
183
|
const found = methodCall(condition, 'startsWith');
|
|
158
184
|
if (!truth || !found || !sameValue(found.receiver, target, checker))
|
|
159
185
|
return false;
|
|
160
|
-
const prefix =
|
|
186
|
+
const prefix = prefixValue(found.call.arguments[0]);
|
|
161
187
|
if (prefix && ts.isStringLiteralLike(prefix))
|
|
162
188
|
return isRootWithSeparator(prefix.text, root);
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
189
|
+
const operands = prefix && prefixOperands(prefix);
|
|
190
|
+
if (!operands)
|
|
191
|
+
return false;
|
|
192
|
+
const [left, right] = operands;
|
|
193
|
+
const resolvedLeft = strip(left);
|
|
194
|
+
return ((sameValue(left, root, checker) ||
|
|
195
|
+
(pathCall(resolvedLeft, 'resolve', context) &&
|
|
196
|
+
resolvedLeft.arguments.length === 1 &&
|
|
197
|
+
sameValue(resolvedLeft.arguments[0], root, checker))) &&
|
|
198
|
+
isPathSeparator(right, checker));
|
|
172
199
|
};
|
|
200
|
+
// The prefix expression, followed through a const name and through
|
|
201
|
+
// `root.endsWith(sep) ? root : <root + sep>`, whose true branch already ends in the separator.
|
|
202
|
+
function prefixValue(node) {
|
|
203
|
+
let value = strip(node);
|
|
204
|
+
const alias = value && ts.isIdentifier(value) && constantDeclaration(value, checker);
|
|
205
|
+
if (alias)
|
|
206
|
+
value = strip(alias.initializer);
|
|
207
|
+
if (!value || !ts.isConditionalExpression(value))
|
|
208
|
+
return value;
|
|
209
|
+
const endsWithSeparator = methodCall(strip(value.condition), 'endsWith');
|
|
210
|
+
const separatorChecked = endsWithSeparator !== undefined &&
|
|
211
|
+
sameValue(endsWithSeparator.receiver, root, checker) &&
|
|
212
|
+
isPathSeparator(endsWithSeparator.call.arguments[0], checker);
|
|
213
|
+
return separatorChecked && sameValue(value.whenTrue, root, checker) ? strip(value.whenFalse) : undefined;
|
|
214
|
+
}
|
|
173
215
|
const rejectsParent = (condition, truth) => {
|
|
174
216
|
const found = methodCall(condition, 'startsWith');
|
|
175
217
|
if (truth || !found)
|
|
@@ -271,6 +313,26 @@ function isProjectValidated(sink, expression, kinds, context) {
|
|
|
271
313
|
}
|
|
272
314
|
const hostFields = new Set(['hostname', 'host', 'origin']);
|
|
273
315
|
const urlValueProperties = new Set([...hostFields, 'href', 'protocol', 'port', 'pathname', 'search', 'hash']);
|
|
316
|
+
function isNonEscapingUrlRead(node, checker) {
|
|
317
|
+
const parent = node.parent;
|
|
318
|
+
if (ts.isPropertyAccessExpression(parent) && parent.expression === node) {
|
|
319
|
+
if (urlValueProperties.has(parent.name.text))
|
|
320
|
+
return true;
|
|
321
|
+
const call = parent.parent;
|
|
322
|
+
return (parent.name.text === 'toString' &&
|
|
323
|
+
ts.isCallExpression(call) &&
|
|
324
|
+
call.expression === parent &&
|
|
325
|
+
call.arguments.length === 0);
|
|
326
|
+
}
|
|
327
|
+
if (ts.isCallExpression(parent) &&
|
|
328
|
+
parent.arguments.length === 1 &&
|
|
329
|
+
parent.arguments[0] === node &&
|
|
330
|
+
isUnshadowedGlobal(strip(parent.expression), 'String', checker))
|
|
331
|
+
return true;
|
|
332
|
+
if (ts.isTemplateSpan(parent) && parent.expression === node)
|
|
333
|
+
return true;
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
274
336
|
function urlReferenceEscapes(sink, target, checker) {
|
|
275
337
|
const scope = scopeOf(sink);
|
|
276
338
|
const declaration = checker.getSymbolAtLocation(target)?.valueDeclaration;
|
|
@@ -284,15 +346,32 @@ function urlReferenceEscapes(sink, target, checker) {
|
|
|
284
346
|
if (node.getStart() >= sinkStart)
|
|
285
347
|
return false;
|
|
286
348
|
if (node !== declaredName && ts.isIdentifier(node) && sameValue(node, target, checker)) {
|
|
287
|
-
|
|
288
|
-
return !ts.isPropertyAccessExpression(parent) || !urlValueProperties.has(parent.name.text);
|
|
349
|
+
return !isNonEscapingUrlRead(node, checker);
|
|
289
350
|
}
|
|
290
351
|
return ts.forEachChild(node, visit);
|
|
291
352
|
})(scope));
|
|
292
353
|
}
|
|
354
|
+
function unwrapUrlString(expression, checker) {
|
|
355
|
+
const value = strip(expression);
|
|
356
|
+
if (ts.isPropertyAccessExpression(value) && value.name.text === 'href')
|
|
357
|
+
return value.expression;
|
|
358
|
+
if (ts.isCallExpression(value)) {
|
|
359
|
+
const callee = strip(value.expression);
|
|
360
|
+
if (value.arguments.length === 0 && ts.isPropertyAccessExpression(callee) && callee.name.text === 'toString')
|
|
361
|
+
return callee.expression;
|
|
362
|
+
if (value.arguments.length === 1 && isUnshadowedGlobal(callee, 'String', checker))
|
|
363
|
+
return value.arguments[0];
|
|
364
|
+
}
|
|
365
|
+
if (ts.isTemplateExpression(value) &&
|
|
366
|
+
value.head.text === '' &&
|
|
367
|
+
value.templateSpans.length === 1 &&
|
|
368
|
+
value.templateSpans[0].literal.text === '')
|
|
369
|
+
return value.templateSpans[0].expression;
|
|
370
|
+
return expression;
|
|
371
|
+
}
|
|
293
372
|
function isAllowedHost(sink, expression, context, hostOnly, acceptsCollection) {
|
|
294
373
|
const { checker } = context;
|
|
295
|
-
const target = stableIdentifier(expression, sink, checker, !hostOnly);
|
|
374
|
+
const target = stableIdentifier(hostOnly ? expression : unwrapUrlString(expression, checker), sink, checker, !hostOnly);
|
|
296
375
|
if (!target)
|
|
297
376
|
return false;
|
|
298
377
|
if (!hostOnly) {
|
|
@@ -318,15 +397,111 @@ function isAllowedHost(sink, expression, context, hostOnly, acceptsCollection) {
|
|
|
318
397
|
return checkedAgainstLiteral(condition, truth, matches, checker);
|
|
319
398
|
});
|
|
320
399
|
}
|
|
400
|
+
function isHttpsOriginList(expression) {
|
|
401
|
+
const list = strip(expression);
|
|
402
|
+
if (!ts.isArrayLiteralExpression(list) || !list.elements.length)
|
|
403
|
+
return false;
|
|
404
|
+
return list.elements.every((entry) => {
|
|
405
|
+
if (!ts.isStringLiteralLike(entry))
|
|
406
|
+
return false;
|
|
407
|
+
const url = URL.parse(entry.text);
|
|
408
|
+
return url?.protocol === 'https:' && url.origin === entry.text;
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
function localOriginPredicate(condition, target, checker) {
|
|
412
|
+
const callee = strip(condition.expression);
|
|
413
|
+
if (!ts.isIdentifier(callee) || !sameValue(condition.arguments[0], target, checker))
|
|
414
|
+
return false;
|
|
415
|
+
const symbol = checker.getSymbolAtLocation(callee);
|
|
416
|
+
const helper = symbol?.valueDeclaration;
|
|
417
|
+
if (!symbol || !helper || !ts.isFunctionDeclaration(helper) || helper.parameters.length !== 1 || !helper.body)
|
|
418
|
+
return false;
|
|
419
|
+
if (helper.asteriskToken || ts.getCombinedModifierFlags(helper) & ts.ModifierFlags.Async)
|
|
420
|
+
return false;
|
|
421
|
+
if (isReassigned(condition.getSourceFile(), symbol, checker))
|
|
422
|
+
return false;
|
|
423
|
+
const parameter = helper.parameters[0].name;
|
|
424
|
+
if (!ts.isIdentifier(parameter))
|
|
425
|
+
return false;
|
|
426
|
+
const statements = helper.body.statements;
|
|
427
|
+
const returned = statements.at(-1);
|
|
428
|
+
if (!returned || !ts.isReturnStatement(returned))
|
|
429
|
+
return false;
|
|
430
|
+
const membership = methodCall(strip(returned.expression), 'includes');
|
|
431
|
+
if (!membership || !sameValue(membership.call.arguments[0], parameter, checker))
|
|
432
|
+
return false;
|
|
433
|
+
if (statements.length === 1)
|
|
434
|
+
return isHttpsOriginList(membership.receiver);
|
|
435
|
+
const first = statements[0];
|
|
436
|
+
if (statements.length !== 2 || !ts.isVariableStatement(first))
|
|
437
|
+
return false;
|
|
438
|
+
const receiver = strip(membership.receiver);
|
|
439
|
+
if (!ts.isIdentifier(receiver))
|
|
440
|
+
return false;
|
|
441
|
+
const declaration = constantDeclaration(receiver, checker);
|
|
442
|
+
return (!!declaration?.initializer &&
|
|
443
|
+
first.declarationList.declarations.length === 1 &&
|
|
444
|
+
first.declarationList.declarations[0] === declaration &&
|
|
445
|
+
isHttpsOriginList(declaration.initializer));
|
|
446
|
+
}
|
|
447
|
+
function isAllowedOriginPrefix(sink, expression, checker) {
|
|
448
|
+
const resolved = strip(expression);
|
|
449
|
+
const target = ts.isIdentifier(resolved) ? strip(constantDeclaration(resolved, checker)?.initializer) : resolved;
|
|
450
|
+
if (!target || !ts.isTemplateExpression(target) || target.head.text !== '' || target.templateSpans.length !== 1)
|
|
451
|
+
return false;
|
|
452
|
+
const [span] = target.templateSpans;
|
|
453
|
+
if (!span.literal.text.startsWith('/'))
|
|
454
|
+
return false;
|
|
455
|
+
const originValue = strip(span.expression);
|
|
456
|
+
if (!ts.isIdentifier(originValue))
|
|
457
|
+
return false;
|
|
458
|
+
const originSymbol = checker.getSymbolAtLocation(originValue);
|
|
459
|
+
const originDeclaration = originSymbol?.valueDeclaration;
|
|
460
|
+
const binding = originDeclaration && ts.isBindingElement(originDeclaration)
|
|
461
|
+
? ts.findAncestor(originDeclaration, ts.isVariableDeclaration)
|
|
462
|
+
: undefined;
|
|
463
|
+
const originScope = originDeclaration ? scopeOf(originDeclaration) : undefined;
|
|
464
|
+
const sinkScope = scopeOf(sink);
|
|
465
|
+
const origin = stableIdentifier(originValue, sink, checker) ??
|
|
466
|
+
(originSymbol &&
|
|
467
|
+
binding &&
|
|
468
|
+
binding.parent.flags & ts.NodeFlags.Const &&
|
|
469
|
+
!isReassigned(sinkScope, originSymbol, checker) &&
|
|
470
|
+
(!originScope || originScope === sinkScope || !isReassigned(originScope, originSymbol, checker))
|
|
471
|
+
? originValue
|
|
472
|
+
: undefined);
|
|
473
|
+
return (!!origin &&
|
|
474
|
+
isGuardedByCondition(sink, (condition, truth) => {
|
|
475
|
+
if (!truth || !ts.isCallExpression(condition) || condition.arguments.length !== 1)
|
|
476
|
+
return false;
|
|
477
|
+
const list = methodCall(condition, 'includes');
|
|
478
|
+
return ((!!list && sameValue(condition.arguments[0], origin, checker) && isHttpsOriginList(list.receiver)) ||
|
|
479
|
+
localOriginPredicate(condition, origin, checker));
|
|
480
|
+
}));
|
|
481
|
+
}
|
|
321
482
|
// Reject characters the URL parser treats as alternate separators or removes before interpreting
|
|
322
483
|
// the path.
|
|
323
484
|
const redirectSeparators = /[\\\t\r\n]/;
|
|
485
|
+
// A guard reads the redirect target when it names the same const or parameter, or the same property
|
|
486
|
+
// chain on a root that nothing reassigns, writes a property of or hands to a call before the redirect.
|
|
487
|
+
function targetMatcher(sink, expression, checker) {
|
|
488
|
+
const target = stableIdentifier(expression, sink, checker);
|
|
489
|
+
if (target)
|
|
490
|
+
return (node) => sameValue(node, target, checker);
|
|
491
|
+
const chain = memberChain(expression);
|
|
492
|
+
const root = chain && stableIdentifier(chain.root, sink, checker, true);
|
|
493
|
+
if (!chain || !root || passesChainOwner(scopeOf(sink), chain, (node) => sameValue(node, root, checker)))
|
|
494
|
+
return;
|
|
495
|
+
return (node) => {
|
|
496
|
+
const candidate = memberChain(node);
|
|
497
|
+
return !!candidate && samePath(candidate.path, chain.path) && sameValue(candidate.root, root, checker);
|
|
498
|
+
};
|
|
499
|
+
}
|
|
324
500
|
function isRelativeRedirect(sink, expression, context) {
|
|
325
501
|
const { checker } = context;
|
|
326
|
-
const
|
|
327
|
-
if (!
|
|
502
|
+
const matches = targetMatcher(sink, expression, checker);
|
|
503
|
+
if (!matches)
|
|
328
504
|
return false;
|
|
329
|
-
const matches = (node) => sameValue(node, target, checker);
|
|
330
505
|
if (isGuardedByCondition(sink, (condition, truth) => checkedAgainstLiteral(condition, truth, matches, checker))) {
|
|
331
506
|
return true;
|
|
332
507
|
}
|
|
@@ -350,4 +525,4 @@ function isRelativeRedirect(sink, expression, context) {
|
|
|
350
525
|
isGuardedByCondition(sink, (condition, truth) => !truth && prefix(condition, '//')) &&
|
|
351
526
|
isGuardedByCondition(sink, (condition, truth) => !truth && unsafeSeparator(condition)));
|
|
352
527
|
}
|
|
353
|
-
export { strip, scopeOf, nameText, propertyValue, calleeName, isResponseReceiver,
|
|
528
|
+
export { strip, scopeOf, nameText, propertyValue, calleeName, isResponseReceiver, hopReason, isHostHeader, constantDeclaration, stableIdentifier, sameValue, checkedAgainstLiteral, urlReferenceEscapes, isContainedPath, isAllowedHost, isAllowedOriginPrefix, isRelativeRedirect, isProjectValidated, };
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
import { ts } from '../../performance/engine/compiler.js';
|
|
3
3
|
import { constInitializer, effectiveProperty, unwrapExpression } from '../../shared/analysis/ast-semantics.js';
|
|
4
4
|
import { importedFrom } from '../bindings.js';
|
|
5
|
-
import { strip, propertyValue,
|
|
5
|
+
import { strip, propertyValue, hopReason, isAllowedHost, isAllowedOriginPrefix, isHostHeader, scopeOf, } from './shared.js';
|
|
6
|
+
import { isParsedHostAllowlisted } from './parsed-host-guard.js';
|
|
7
|
+
import { isGlobalIdentifier } from '../../shared/analysis/ast-helpers.js';
|
|
6
8
|
const ruleId = 'ssrf-request-url';
|
|
7
9
|
const message = (label) => `The request URL host comes from \`${label}\`, so a caller can make this server reach internal addresses. Parse it with \`new URL()\` and allow only known hosts, or build the URL from a fixed origin.`;
|
|
8
10
|
const hostHeaderReason = 'The host comes from the Host header; a reverse proxy that accepts only known hosts makes this unreachable.';
|
|
@@ -96,9 +98,140 @@ function urlArguments(call, client) {
|
|
|
96
98
|
}
|
|
97
99
|
return found;
|
|
98
100
|
}
|
|
101
|
+
// Options the filtering-agent proof reads, including got's `agent: { http, https }` object. A write
|
|
102
|
+
// to another field, such as `headers` or `timeout`, cannot replace the agent.
|
|
103
|
+
const transportOptionNames = new Set(['agent', 'httpAgent', 'httpsAgent', 'dispatcher', 'http', 'https']);
|
|
104
|
+
function writesTransportOption(access) {
|
|
105
|
+
if (ts.isPropertyAccessExpression(access))
|
|
106
|
+
return transportOptionNames.has(access.name.text);
|
|
107
|
+
const key = unwrapExpression(access.argumentExpression);
|
|
108
|
+
// A computed key can name any field.
|
|
109
|
+
return !key || !ts.isStringLiteralLike(key) || transportOptionNames.has(key.text);
|
|
110
|
+
}
|
|
111
|
+
function isMutatedPropertyAccess(access) {
|
|
112
|
+
const parent = access.parent;
|
|
113
|
+
if (ts.isDeleteExpression(parent))
|
|
114
|
+
return true;
|
|
115
|
+
if ((ts.isPrefixUnaryExpression(parent) || ts.isPostfixUnaryExpression(parent)) &&
|
|
116
|
+
(parent.operator === ts.SyntaxKind.PlusPlusToken || parent.operator === ts.SyntaxKind.MinusMinusToken))
|
|
117
|
+
return true;
|
|
118
|
+
return (ts.isBinaryExpression(parent) &&
|
|
119
|
+
parent.left === access &&
|
|
120
|
+
parent.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&
|
|
121
|
+
parent.operatorToken.kind <= ts.SyntaxKind.LastAssignment);
|
|
122
|
+
}
|
|
123
|
+
// Calls that read an options object without keeping or changing it.
|
|
124
|
+
const readOnlyCallees = new Set([
|
|
125
|
+
'JSON.stringify',
|
|
126
|
+
'Object.keys',
|
|
127
|
+
'Object.values',
|
|
128
|
+
'Object.entries',
|
|
129
|
+
'structuredClone',
|
|
130
|
+
]);
|
|
131
|
+
const mutatingCallees = new Set(['Object.assign', 'Object.defineProperty', 'Object.defineProperties']);
|
|
132
|
+
const hazardsByDeclaration = new WeakMap();
|
|
133
|
+
function isWrapperNode(node) {
|
|
134
|
+
return (ts.isParenthesizedExpression(node) ||
|
|
135
|
+
ts.isAsExpression(node) ||
|
|
136
|
+
ts.isNonNullExpression(node) ||
|
|
137
|
+
ts.isSatisfiesExpression(node) ||
|
|
138
|
+
ts.isTypeAssertionExpression(node));
|
|
139
|
+
}
|
|
140
|
+
function isHazardousReference(reference, context) {
|
|
141
|
+
let child = reference;
|
|
142
|
+
while (isWrapperNode(child.parent))
|
|
143
|
+
child = child.parent;
|
|
144
|
+
const parent = child.parent;
|
|
145
|
+
if ((ts.isPropertyAccessExpression(parent) || ts.isElementAccessExpression(parent)) && parent.expression === child)
|
|
146
|
+
return isMutatedPropertyAccess(parent) && writesTransportOption(parent);
|
|
147
|
+
if (ts.isCallExpression(parent) || ts.isNewExpression(parent)) {
|
|
148
|
+
if (!parent.arguments?.some((argument) => argument === child))
|
|
149
|
+
return false;
|
|
150
|
+
if (ts.isNewExpression(parent))
|
|
151
|
+
return true;
|
|
152
|
+
const calleeText = parent.expression.getText();
|
|
153
|
+
if (mutatingCallees.has(calleeText))
|
|
154
|
+
return parent.arguments[0] === child;
|
|
155
|
+
if (readOnlyCallees.has(calleeText) || calleeText.startsWith('console.'))
|
|
156
|
+
return false;
|
|
157
|
+
return !clientCall(parent, context);
|
|
158
|
+
}
|
|
159
|
+
if (ts.isVariableDeclaration(parent))
|
|
160
|
+
return parent.initializer === child && ts.isIdentifier(parent.name);
|
|
161
|
+
if (ts.isBinaryExpression(parent))
|
|
162
|
+
return (parent.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&
|
|
163
|
+
parent.operatorToken.kind <= ts.SyntaxKind.LastAssignment);
|
|
164
|
+
return (ts.isShorthandPropertyAssignment(parent) ||
|
|
165
|
+
ts.isPropertyAssignment(parent) ||
|
|
166
|
+
ts.isReturnStatement(parent) ||
|
|
167
|
+
ts.isArrayLiteralExpression(parent) ||
|
|
168
|
+
ts.isArrowFunction(parent) ||
|
|
169
|
+
ts.isExportAssignment(parent) ||
|
|
170
|
+
ts.isYieldExpression(parent));
|
|
171
|
+
}
|
|
172
|
+
// Every hazardous reference to the options object, found once per declaration.
|
|
173
|
+
function optionsHazards(declaration, symbol, context) {
|
|
174
|
+
const cached = hazardsByDeclaration.get(declaration);
|
|
175
|
+
if (cached)
|
|
176
|
+
return cached;
|
|
177
|
+
const declarationScope = scopeOf(declaration);
|
|
178
|
+
const hazards = [];
|
|
179
|
+
const referencesOptions = (identifier) => {
|
|
180
|
+
const parent = identifier.parent;
|
|
181
|
+
// `typeof options` names the variable in a type; it reads no runtime value.
|
|
182
|
+
if (ts.isTypeQueryNode(parent))
|
|
183
|
+
return false;
|
|
184
|
+
const referenced = ts.isShorthandPropertyAssignment(parent) && parent.name === identifier
|
|
185
|
+
? context.checker.getShorthandAssignmentValueSymbol(parent)
|
|
186
|
+
: context.checker.getSymbolAtLocation(identifier);
|
|
187
|
+
return referenced === symbol;
|
|
188
|
+
};
|
|
189
|
+
(function visit(node) {
|
|
190
|
+
if (ts.isIdentifier(node) &&
|
|
191
|
+
node !== declaration.name &&
|
|
192
|
+
referencesOptions(node) &&
|
|
193
|
+
isHazardousReference(node, context))
|
|
194
|
+
hazards.push({ node, inNestedFunction: scopeOf(node) !== declarationScope });
|
|
195
|
+
ts.forEachChild(node, visit);
|
|
196
|
+
})(declarationScope);
|
|
197
|
+
hazardsByDeclaration.set(declaration, hazards);
|
|
198
|
+
return hazards;
|
|
199
|
+
}
|
|
200
|
+
// The loops around `use` inside its function: a later statement in a loop runs before the next pass.
|
|
201
|
+
function enclosingLoops(use) {
|
|
202
|
+
const loops = [];
|
|
203
|
+
for (let node = use.parent; node && !ts.isFunctionLike(node); node = node.parent)
|
|
204
|
+
if (ts.isIterationStatement(node, false))
|
|
205
|
+
loops.push(node);
|
|
206
|
+
return loops;
|
|
207
|
+
}
|
|
208
|
+
// True when the options object may change, or be reached through another name, before `use` reads it.
|
|
209
|
+
function optionsMutatedOrEscaped(use, declaration, context) {
|
|
210
|
+
const symbol = context.checker.getSymbolAtLocation(declaration.name);
|
|
211
|
+
if (!symbol)
|
|
212
|
+
return true;
|
|
213
|
+
if (ts.getCombinedModifierFlags(declaration) & ts.ModifierFlags.Export)
|
|
214
|
+
return true;
|
|
215
|
+
const hazards = optionsHazards(declaration, symbol, context);
|
|
216
|
+
if (!hazards.length)
|
|
217
|
+
return false;
|
|
218
|
+
if (scopeOf(declaration) !== scopeOf(use))
|
|
219
|
+
return true;
|
|
220
|
+
const useStart = use.getStart();
|
|
221
|
+
// A loop body that also declares the options builds a fresh object each pass; a `for` initializer runs once, so that loop carries it.
|
|
222
|
+
const loops = enclosingLoops(use).filter((loop) => declaration.getStart() < loop.getStart() ||
|
|
223
|
+
declaration.getEnd() > loop.getEnd() ||
|
|
224
|
+
(ts.isForStatement(loop) && loop.initializer === declaration.parent));
|
|
225
|
+
return hazards.some(({ node, inNestedFunction }) => inNestedFunction ||
|
|
226
|
+
node.getStart() < useStart ||
|
|
227
|
+
loops.some((loop) => node.getStart() >= loop.getStart() && node.getEnd() <= loop.getEnd()));
|
|
228
|
+
}
|
|
99
229
|
function optionsObject(expression, context) {
|
|
100
230
|
let current = unwrapExpression(expression);
|
|
101
231
|
for (let depth = 0; depth < 4 && ts.isIdentifier(current); depth++) {
|
|
232
|
+
const declaration = context.checker.getSymbolAtLocation(current)?.valueDeclaration;
|
|
233
|
+
if (declaration && ts.isVariableDeclaration(declaration) && optionsMutatedOrEscaped(current, declaration, context))
|
|
234
|
+
return;
|
|
102
235
|
const initializer = constInitializer(current, context.checker);
|
|
103
236
|
if (!initializer)
|
|
104
237
|
return;
|
|
@@ -278,8 +411,12 @@ function checkRequestUrl(call, context) {
|
|
|
278
411
|
const control = hostOnly ? hostControl(expression, context) : context.taint.urlControl(expression);
|
|
279
412
|
if (!control || (control.part === 'path' && !control.rawPathname))
|
|
280
413
|
continue;
|
|
414
|
+
if (!hostOnly && isAllowedOriginPrefix(call, expression, context.checker))
|
|
415
|
+
continue;
|
|
281
416
|
if (isAllowedHost(call, expression, context, hostOnly))
|
|
282
417
|
continue;
|
|
418
|
+
if (!hostOnly && isParsedHostAllowlisted(call, optionsUrl(expression, context), context.checker))
|
|
419
|
+
continue;
|
|
283
420
|
const { trace } = control;
|
|
284
421
|
const reason = (control.part === 'path' ? 'The host is fixed; only the URL path is derived from input.' : undefined) ??
|
|
285
422
|
hopReason(trace) ??
|
|
@@ -288,6 +425,13 @@ function checkRequestUrl(call, context) {
|
|
|
288
425
|
return;
|
|
289
426
|
}
|
|
290
427
|
}
|
|
428
|
+
// The `url` of a named options object (`axios.request(options)`) when no other field picks the host.
|
|
429
|
+
function optionsUrl(expression, context) {
|
|
430
|
+
const options = ts.isIdentifier(unwrapExpression(expression)) && optionsObject(expression, context);
|
|
431
|
+
if (!options || ['baseURL', 'prefixUrl', 'origin', 'hostname', 'host'].some((name) => propertyValue(options, name)))
|
|
432
|
+
return expression;
|
|
433
|
+
return effectiveOption(options, 'url', context) ?? expression;
|
|
434
|
+
}
|
|
291
435
|
function hostControl(expression, context) {
|
|
292
436
|
const trace = context.taint.trace(expression, 'url');
|
|
293
437
|
return trace && { part: 'host', trace };
|
|
@@ -2,20 +2,31 @@
|
|
|
2
2
|
const descriptionByRule = {
|
|
3
3
|
'angular-bypass-security-trust': "DomSanitizer.bypassSecurityTrust* is called on a dynamic value, which turns off Angular's built-in sanitization.",
|
|
4
4
|
'auth-route-without-rate-limit': 'A login, signup or password-reset route has no rate limiter.',
|
|
5
|
+
'azure-pipelines-script-injection': 'An Azure Pipelines script pastes a commit message or branch name into its text with a $(...) macro.',
|
|
5
6
|
'bcrypt-low-cost': 'A bcrypt password hash uses a work factor below the recommended minimum.',
|
|
7
|
+
'bitbucket-pipelines-script-injection': 'A Bitbucket Pipelines script passes the branch name to eval or inline code, which parses it as commands.',
|
|
8
|
+
'bitbucket-pipelines-unpinned-image': 'A Bitbucket Pipelines build image has no version tag or uses :latest.',
|
|
9
|
+
'circleci-script-injection': 'A CircleCI run command pastes a branch name or commit text into its text, or passes it to eval or inline code.',
|
|
10
|
+
'circleci-unpinned-image': 'A CircleCI Docker executor image has no version tag or uses :latest.',
|
|
11
|
+
'circleci-unpinned-orb': 'A CircleCI orb is used at the moving @volatile or a dev: version.',
|
|
6
12
|
'client-env-secret-exposed': 'A secret-named env variable is read under a browser prefix (NEXT_PUBLIC_, VITE_, REACT_APP_...), so the build ships it to every visitor.',
|
|
7
13
|
'code-injection': 'Request-controlled input becomes source code evaluated by the application.',
|
|
8
14
|
'command-injection': 'Request-controlled input reaches a shell command string.',
|
|
9
15
|
'committed-secret': 'A tracked file contains a value that appears to be a credential.',
|
|
10
16
|
'compose-hardcoded-secret': 'A Docker Compose service supplies a secret as a literal environment value.',
|
|
17
|
+
'config-cors-credentials-any-origin': 'A web server or hosting config sends Access-Control-Allow-Credentials: true with a wildcard or echoed request origin.',
|
|
18
|
+
'config-unsafe-security-header': "A web server or hosting config sets a security header to a value that disables it, such as X-Frame-Options: ALLOWALL or CSP 'unsafe-eval'.",
|
|
11
19
|
'cookie-missing-security-flags': 'A sensitive cookie is set without the expected security attributes.',
|
|
12
20
|
'cors-credentials-any-origin': 'A credentialed CORS response allows arbitrary origins.',
|
|
13
21
|
'cors-origin-regex-unanchored': 'A CORS origin regex also accepts look-alike hosts.',
|
|
22
|
+
'csharp-binaryformatter-request-deserialization': 'Legacy BinaryFormatter.Deserialize consumes an ASP.NET Core request stream.',
|
|
14
23
|
'csharp-ef-from-sql-raw': 'FromSqlRaw or ExecuteSqlRaw receives a concatenated or interpolated string, risking SQL injection.',
|
|
15
24
|
'csharp-process-start': 'Process.Start launches an external process and risks command injection with untrusted arguments.',
|
|
16
25
|
'database-error-in-response': 'An HTTP response includes a raw database error message.',
|
|
17
26
|
'dependency-known-vulnerability': 'A resolved dependency version is listed in a published vulnerability advisory.',
|
|
27
|
+
'discarded-signature-verification-result': 'A standalone call discards the result of Node.js synchronous signature verification.',
|
|
18
28
|
'dockerfile-add-remote-url': 'A Dockerfile ADD instruction retrieves a resource from a remote URL.',
|
|
29
|
+
'dockerfile-npm-install': 'A Dockerfile runs `npm install` after copying the lockfile, so the image can resolve versions the lockfile does not pin.',
|
|
19
30
|
'dockerfile-runs-as-root': 'The final image selects root or inherits an unverified base-image user.',
|
|
20
31
|
'dockerfile-secret-in-build': 'A Dockerfile exposes a secret through a build argument or environment variable.',
|
|
21
32
|
'dockerfile-unpinned-base-image': 'A Dockerfile uses a base image reference that can change between builds.',
|
|
@@ -27,6 +38,12 @@ const descriptionByRule = {
|
|
|
27
38
|
'express-cookie-auth-missing-csrf': 'Cookie-based session or auth is paired with state-changing routes without CSRF protection or `sameSite: "strict"`.',
|
|
28
39
|
'express-missing-helmet': 'The Express or NestJS server starts without helmet security headers middleware (contextual: a proxy may set them).',
|
|
29
40
|
'frontend-storage-secret-token': 'A token, JWT, password or API key is stored in localStorage or sessionStorage, readable by any script on the page.',
|
|
41
|
+
'github-actions-pull-request-target-checkout': 'A pull_request_target or workflow_run workflow checks out the pull request code with the base repository secrets.',
|
|
42
|
+
'github-actions-script-injection': 'A workflow script expands attacker-controlled event text such as an issue title or branch name.',
|
|
43
|
+
'github-actions-unpinned-action': 'A workflow runs a third-party action from a tag or branch instead of a commit SHA.',
|
|
44
|
+
'gitlab-ci-script-injection': 'A GitLab CI script passes commit, merge request or branch text to eval or inline code, which parses it as commands.',
|
|
45
|
+
'gitlab-ci-unpinned-image': 'A GitLab CI job image has no version tag or uses :latest.',
|
|
46
|
+
'gitlab-ci-unpinned-include': 'A GitLab CI include loads another project, a remote URL or a component from a moving branch or version.',
|
|
30
47
|
'go-exec-command-shell': 'exec.Command invokes a shell, which risks command injection.',
|
|
31
48
|
'go-sql-sprintf-injection': 'SQL text formatted with fmt.Sprintf risks SQL injection.',
|
|
32
49
|
'go-tls-insecure-skip-verify': 'Setting InsecureSkipVerify: true on tls.Config disables TLS certificate verification.',
|
|
@@ -34,10 +51,17 @@ const descriptionByRule = {
|
|
|
34
51
|
'graphql-introspection-enabled': 'A GraphQL server explicitly enables schema introspection.',
|
|
35
52
|
'graphql-query-depth-unbounded': 'A GraphQL server accepts queries of any depth.',
|
|
36
53
|
'hardcoded-secret': 'The source supplies a literal credential or cryptographic secret.',
|
|
54
|
+
'hosting-redirect-external-wildcard': 'A vercel.json, netlify.toml or _redirects redirect takes its destination host from the request path (open redirect).',
|
|
37
55
|
'insecure-cipher': 'A cryptographic operation selects an insecure cipher or mode.',
|
|
56
|
+
'insecure-deserialization': 'Request data is deserialized by a library that can rebuild and run functions from it.',
|
|
38
57
|
'insecure-random-for-secret': 'A sensitive token or secret uses a non-cryptographic random source.',
|
|
58
|
+
'java-des-cipher': 'A JCA Cipher factory explicitly selects DES.',
|
|
59
|
+
'java-objectinputstream-request-deserialization': 'Java ObjectInputStream.readObject consumes a servlet request body.',
|
|
39
60
|
'java-runtime-exec': 'Runtime.getRuntime().exec runs an OS command and risks command injection with untrusted arguments.',
|
|
40
61
|
'java-sql-string-concat': 'A SQL query built by string concatenation risks SQL injection.',
|
|
62
|
+
'jenkinsfile-credential-interpolation': 'A Jenkinsfile shell step interpolates a bound credential with a Groovy double-quoted string.',
|
|
63
|
+
'jenkinsfile-script-injection': 'A Jenkinsfile shell step interpolates a branch name, pull request field or build parameter into its script.',
|
|
64
|
+
'js-yaml-unsafe-schema': 'A resolved js-yaml loader enables JavaScript-specific YAML constructors.',
|
|
41
65
|
'jsx-javascript-url': 'In React 18 and older or Preact, a URL search parameter or location hash starts a JSX href, action or iframe src (javascript: XSS).',
|
|
42
66
|
'jwt-decode-for-auth': 'Authentication uses decoded JWT claims without verifying the token signature.',
|
|
43
67
|
'jwt-none-algorithm': 'JWT signing or verification allows an unsigned token.',
|
|
@@ -45,13 +69,18 @@ const descriptionByRule = {
|
|
|
45
69
|
'jwt-verify-without-algorithms': 'JWT verification does not restrict the accepted signing algorithms.',
|
|
46
70
|
'jwt-weak-secret-literal': 'JWT signing or verification uses a short (< 32 chars) or weak literal secret susceptible to brute-force forgery.',
|
|
47
71
|
'knex-raw-dynamic-text': 'A dynamic SQL fragment reaches Knex without parameter binding.',
|
|
72
|
+
'kubernetes-privileged-container': 'A Kubernetes workload explicitly requests a privileged container.',
|
|
73
|
+
'kysely-scope-unverified': 'A Kysely read lacks the row scope required by the declared policy.',
|
|
48
74
|
'ldap-filter-injection': 'Request data reaches an LDAP search filter without RFC 4515 filter escaping or a filter builder.',
|
|
49
75
|
'mass-assignment': 'An unfiltered request body reaches a persistence operation.',
|
|
50
76
|
'mysql-dynamic-query-text': 'Dynamic SQL text reaches a MySQL client without parameter binding.',
|
|
51
77
|
'nest-validation-without-whitelist': 'A NestJS ValidationPipe permits properties outside the validated DTO.',
|
|
52
78
|
'next-image-any-remote-host': "A Next.js images.remotePatterns entry sets hostname '**', so the image optimizer fetches and serves any host (open proxy).",
|
|
79
|
+
'nginx-proxy-pass-request-host': 'An Nginx proxy_pass takes its upstream host from a client-sent value such as $http_host or a query argument.',
|
|
53
80
|
'nosql-operator-injection': 'Request data can introduce query operators into a NoSQL filter.',
|
|
54
81
|
'open-redirect': 'An HTTP redirect destination is controlled by request data.',
|
|
82
|
+
'package-script-remote-code': 'A package.json install lifecycle script downloads code and runs it, for example `curl ... | sh`.',
|
|
83
|
+
'package-script-tls-verification-disabled': 'A package.json script turns off TLS certificate verification, for example NODE_TLS_REJECT_UNAUTHORIZED=0 or strict-ssl false.',
|
|
55
84
|
'password-hash-in-response': 'A response returns a user record that still holds its password hash.',
|
|
56
85
|
'path-traversal': 'Request data controls a filesystem path without a recognized containment check.',
|
|
57
86
|
'pg-dynamic-query-text': 'Dynamic SQL text reaches the PostgreSQL client without parameter binding.',
|
|
@@ -62,12 +91,15 @@ const descriptionByRule = {
|
|
|
62
91
|
'prototype-pollution': 'Request data can supply keys to a write or merge that can modify an object prototype.',
|
|
63
92
|
'python-insecure-deserialization': 'pickle or marshal deserialization of untrusted data can execute arbitrary code.',
|
|
64
93
|
'python-requests-tls-verify-disabled': 'Calling Python requests with verify=False disables TLS certificate verification.',
|
|
94
|
+
'python-sqlite-unbound-value': 'A Python sqlite3 query inserts a value into SQL text instead of binding it.',
|
|
65
95
|
'python-subprocess-shell-true': 'subprocess with shell=True or os.system passes input through a shell, risking command injection.',
|
|
66
|
-
'python-unsafe-yaml-load': 'yaml.load or yaml.load_all without SafeLoader can construct arbitrary Python objects.',
|
|
96
|
+
'python-unsafe-yaml-load': 'yaml.load or yaml.load_all without SafeLoader or BaseLoader can construct arbitrary Python objects.',
|
|
97
|
+
'raw-content-disposition-filename': 'Request data is interpolated into a raw Content-Disposition filename parameter.',
|
|
67
98
|
'react-dangerously-set-inner-html': 'dangerouslySetInnerHTML receives HTML that is not a constant or sanitized.',
|
|
68
99
|
'reflected-xss-response': 'An HTML response reflects request data without recognized escaping.',
|
|
69
100
|
'regex-catastrophic-backtracking': 'A regular expression that can backtrack exponentially or in polynomial time runs on request input.',
|
|
70
101
|
'regex-from-input': 'Request input supplies a regular expression pattern without recognized escaping.',
|
|
102
|
+
'request-selected-executable': 'Request input selects the program at a resolved process-launch API.',
|
|
71
103
|
'rust-command-shell': 'Command::new("sh") or Command::new("bash") spawns a shell and risks command injection.',
|
|
72
104
|
'rust-reqwest-danger-accept-invalid-certs': 'Calling danger_accept_invalid_certs(true) on a reqwest client disables TLS certificate verification.',
|
|
73
105
|
'rust-unsafe-raw-pointer-deref': 'A raw pointer dereference in an unsafe block bypasses Rust memory safety guarantees.',
|
|
@@ -81,13 +113,26 @@ const descriptionByRule = {
|
|
|
81
113
|
'storage-object-public-acl': 'A storage upload makes the object publicly readable.',
|
|
82
114
|
'template-autoescape-disabled': 'A template engine is configured to render values without HTML escaping.',
|
|
83
115
|
'template-injection': 'Request data is interpreted as template source rather than a template value.',
|
|
116
|
+
'template-raw-html-binding': 'A Vue or Svelte template inserts a dynamic value as raw HTML.',
|
|
117
|
+
'terraform-admin-port-open-to-world': 'A Terraform firewall rule opens an SSH, RDP or database port to every internet address.',
|
|
118
|
+
'terraform-database-publicly-accessible': 'A Terraform database is reachable from the public internet.',
|
|
119
|
+
'terraform-hardcoded-credential': 'A Terraform provider, resource or module sets a credential to a literal value.',
|
|
120
|
+
'terraform-storage-bucket-public': 'A Terraform storage bucket or container grants anonymous public access.',
|
|
121
|
+
'terraform-storage-encryption-disabled': 'A Terraform resource explicitly turns off encryption at rest.',
|
|
84
122
|
'tls-verification-disabled': 'A TLS client skips certificate or server hostname verification.',
|
|
123
|
+
'trust-boundary-violation': 'Request data is stored in application-wide state that later requests trust.',
|
|
85
124
|
'typeorm-dynamic-query-text': 'A dynamic SQL fragment reaches TypeORM without parameter binding.',
|
|
86
125
|
'upload-client-filename': 'A file upload is stored under the original name supplied by the client.',
|
|
87
126
|
'vm-sandbox-escape': 'Node `vm` or `vm2` executes dynamic code or an untrusted context, risking sandbox escape and host RCE.',
|
|
88
127
|
'vue-v-html-unsanitized': 'A Vue render function binds unsanitized dynamic HTML to innerHTML.',
|
|
128
|
+
'weak-hash': 'A request credential is hashed with MD5 or SHA-1.',
|
|
89
129
|
'weak-password-hash': 'A password is hashed with an algorithm unsuitable for password storage.',
|
|
130
|
+
'web-server-directory-listing': 'An Nginx or Apache config turns on directory listing (autoindex on or Options Indexes).',
|
|
131
|
+
'web-server-legacy-tls': 'An Nginx or Apache config enables SSLv3, TLSv1 or TLSv1.1.',
|
|
132
|
+
'web-server-version-exposed': 'An Nginx or Apache config explicitly adds the server version to response headers.',
|
|
133
|
+
'webhook-body-without-verification': 'A Stripe webhook writes request-body data before visible signature verification.',
|
|
90
134
|
'xml-external-entities': 'An XML parser allows processing of external entities.',
|
|
135
|
+
'xpath-injection': 'Request data is concatenated into an XPath expression.',
|
|
91
136
|
'zip-slip-extraction': 'An archive entry controls an extraction path without a recognized containment check.',
|
|
92
137
|
};
|
|
93
138
|
export { descriptionByRule };
|