loadwise 0.0.0-stage → 0.5.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/LICENSE +201 -0
- package/PERFORMANCE.md +110 -0
- package/README.md +1429 -2
- package/bin/github-action.js +58 -0
- package/bin/loadwise.js +98 -0
- package/editor/README.md +47 -0
- package/editor/accessibility-examples.cjs +90 -0
- package/editor/apply-fix.cjs +187 -0
- package/editor/control-flow-comparison.cjs +133 -0
- package/editor/finding-comparison.cjs +77 -0
- package/editor/maintainability-examples.cjs +229 -0
- package/editor/perf-site-comparison.cjs +85 -0
- package/editor/performance-examples.cjs +438 -0
- package/editor/reliability-examples.cjs +77 -0
- package/editor/security-examples.cjs +59 -0
- package/editor/source-example.cjs +66 -0
- package/editor/standalone-performance-examples.cjs +487 -0
- package/examples/indexed.ts +19 -0
- package/examples/labels.py +6 -0
- package/examples/mongo-plan.json +8 -0
- package/examples/postgres-plan.json +10 -0
- package/examples/query-policy.json +24 -0
- package/examples/redis-keys.otlp.json +22 -0
- package/examples/repeated-db.otlp.json +73 -0
- package/examples/slow.ts +10 -0
- package/examples/tsconfig.json +4 -0
- package/lib/accessibility/analyze.js +26 -0
- package/lib/accessibility/angular-inline.js +43 -0
- package/lib/accessibility/aria-tables.js +231 -0
- package/lib/accessibility/cli.js +11 -0
- package/lib/accessibility/frontend-detect.js +98 -0
- package/lib/accessibility/jsx-elements.js +110 -0
- package/lib/accessibility/markup-files.js +41 -0
- package/lib/accessibility/markup.js +24 -0
- package/lib/accessibility/rule-ids.js +36 -0
- package/lib/accessibility/rules.js +293 -0
- package/lib/accessibility/site-fixes/buttons.js +35 -0
- package/lib/accessibility/template-attributes.js +135 -0
- package/lib/accessibility/template-elements.js +434 -0
- package/lib/accessibility/template-file.js +183 -0
- package/lib/accessibility/usage.js +12 -0
- package/lib/maintainability/advisory-context.js +182 -0
- package/lib/maintainability/analyze-source.js +93 -0
- package/lib/maintainability/ancestor-aliases.js +35 -0
- package/lib/maintainability/apply-fix.js +85 -0
- package/lib/maintainability/architecture-nest.js +103 -0
- package/lib/maintainability/architecture.js +482 -0
- package/lib/maintainability/branch-advice.js +135 -0
- package/lib/maintainability/changed-lines.js +135 -0
- package/lib/maintainability/changed-output.js +21 -0
- package/lib/maintainability/checklist-context.js +74 -0
- package/lib/maintainability/child-buffer.js +20 -0
- package/lib/maintainability/cli.js +410 -0
- package/lib/maintainability/config-entry-points.js +86 -0
- package/lib/maintainability/data-access.js +153 -0
- package/lib/maintainability/deprecated-apis.js +170 -0
- package/lib/maintainability/docker-entry-points.js +98 -0
- package/lib/maintainability/duplicates.js +326 -0
- package/lib/maintainability/entry-points.js +603 -0
- package/lib/maintainability/examples.js +122 -0
- package/lib/maintainability/finding-ids.js +46 -0
- package/lib/maintainability/fix-cli.js +235 -0
- package/lib/maintainability/fix-text.js +11 -0
- package/lib/maintainability/functions.js +315 -0
- package/lib/maintainability/graph.js +186 -0
- package/lib/maintainability/html-entry-points.js +75 -0
- package/lib/maintainability/inputs.js +231 -0
- package/lib/maintainability/layout.js +56 -0
- package/lib/maintainability/limits.js +3 -0
- package/lib/maintainability/mocha-entry-points.js +88 -0
- package/lib/maintainability/modifiers.js +6 -0
- package/lib/maintainability/module-usage-dynamic.js +175 -0
- package/lib/maintainability/module-usage.js +574 -0
- package/lib/maintainability/notify-editor.js +1 -0
- package/lib/maintainability/operator-references.js +84 -0
- package/lib/maintainability/polyglot-duplicates.js +121 -0
- package/lib/maintainability/polyglot.js +173 -0
- package/lib/maintainability/project.js +116 -0
- package/lib/maintainability/review-directive.js +91 -0
- package/lib/maintainability/rule-ids.js +67 -0
- package/lib/maintainability/runtime-directories.js +22 -0
- package/lib/maintainability/scan-changed.js +67 -0
- package/lib/maintainability/scan-worker.js +38 -0
- package/lib/maintainability/scan.js +238 -0
- package/lib/maintainability/site-fix.js +221 -0
- package/lib/maintainability/site-fixes/boolean-returns.js +79 -0
- package/lib/maintainability/site-fixes/branches.js +418 -0
- package/lib/maintainability/site-fixes/control-flow.js +67 -0
- package/lib/maintainability/site-fixes/cycles.js +101 -0
- package/lib/maintainability/site-fixes/deprecated-apis.js +67 -0
- package/lib/maintainability/site-fixes/duplicate-arrows.js +343 -0
- package/lib/maintainability/site-fixes/duplicate-bindings.js +149 -0
- package/lib/maintainability/site-fixes/duplicate-edits.js +396 -0
- package/lib/maintainability/site-fixes/duplicate-methods.js +407 -0
- package/lib/maintainability/site-fixes/duplicates.js +125 -0
- package/lib/maintainability/site-fixes/exports.js +25 -0
- package/lib/maintainability/site-fixes/extract-block-ast.js +130 -0
- package/lib/maintainability/site-fixes/extract-block-edits.js +156 -0
- package/lib/maintainability/site-fixes/extract-block-flow.js +265 -0
- package/lib/maintainability/site-fixes/extract-block-measure.js +131 -0
- package/lib/maintainability/site-fixes/extract-block-naming.js +164 -0
- package/lib/maintainability/site-fixes/extract-block-narrowing.js +141 -0
- package/lib/maintainability/site-fixes/extract-block.js +38 -0
- package/lib/maintainability/site-fixes/helpers.js +308 -0
- package/lib/maintainability/site-fixes/if-rewrites.js +468 -0
- package/lib/maintainability/site-fixes/isolated-program.js +85 -0
- package/lib/maintainability/site-fixes/large-module.js +175 -0
- package/lib/maintainability/site-fixes/parameters.js +460 -0
- package/lib/maintainability/site-fixes/stray-console.js +21 -0
- package/lib/maintainability/site-fixes/unused-bindings.js +158 -0
- package/lib/maintainability/size-limits.js +94 -0
- package/lib/maintainability/snapshot-context.js +63 -0
- package/lib/maintainability/source-exclusions.js +68 -0
- package/lib/maintainability/source-facts.js +39 -0
- package/lib/maintainability/stray-console.js +352 -0
- package/lib/maintainability/traversal-context.js +76 -0
- package/lib/maintainability/types/changed-lines.js +1 -0
- package/lib/maintainability/types/created-module.js +1 -0
- package/lib/maintainability/types/duplicate-sites.js +1 -0
- package/lib/maintainability/types/duplicates.js +1 -0
- package/lib/maintainability/types/entry-points.js +1 -0
- package/lib/maintainability/types/extract-block.js +1 -0
- package/lib/maintainability/types/extraction-drafts.js +1 -0
- package/lib/maintainability/types/finding-comparison.js +1 -0
- package/lib/maintainability/types/fix-files.js +1 -0
- package/lib/maintainability/types/module-graph.js +1 -0
- package/lib/maintainability/types/module-resolver.js +1 -0
- package/lib/maintainability/types/module-usage.js +1 -0
- package/lib/maintainability/types/policy.js +1 -0
- package/lib/maintainability/types/polyglot-scan.js +1 -0
- package/lib/maintainability/types/scan-report.js +1 -0
- package/lib/maintainability/types/scan-worker.js +1 -0
- package/lib/maintainability/types/site-fix-edits.js +1 -0
- package/lib/maintainability/types/site-fix-loader.js +1 -0
- package/lib/maintainability/types/site-fix-nodes.js +1 -0
- package/lib/maintainability/types/source-analysis.js +1 -0
- package/lib/maintainability/types/source-facts.js +1 -0
- package/lib/maintainability/types/typescript-jsdoc-internals.js +1 -0
- package/lib/maintainability/types/typescript-site-fix-internals.js +1 -0
- package/lib/maintainability/unused-bindings.js +182 -0
- package/lib/maintainability/unused-modules.js +258 -0
- package/lib/maintainability/verified-private-types.js +142 -0
- package/lib/maintainability/walk.js +17 -0
- package/lib/maintainability/workflow-entry-points.js +83 -0
- package/lib/performance/analyze.js +251 -0
- package/lib/performance/async-errors.js +190 -0
- package/lib/performance/await-before-early-exit.js +176 -0
- package/lib/performance/awaits.js +70 -0
- package/lib/performance/backend-mastery.js +444 -0
- package/lib/performance/cache-reads.js +170 -0
- package/lib/performance/call-syntax.js +27 -0
- package/lib/performance/cartesian-includes.js +364 -0
- package/lib/performance/changed-lines.js +141 -0
- package/lib/performance/cli-arguments.js +61 -0
- package/lib/performance/cli-output.js +175 -0
- package/lib/performance/cli-policy.js +79 -0
- package/lib/performance/cli-scan.js +419 -0
- package/lib/performance/cli-types.js +1 -0
- package/lib/performance/cli.js +120 -0
- package/lib/performance/collection-bindings.js +283 -0
- package/lib/performance/collection-bounds.js +247 -0
- package/lib/performance/collection-copy.js +169 -0
- package/lib/performance/collection-lookups.js +432 -0
- package/lib/performance/collection-reduce.js +340 -0
- package/lib/performance/collections.js +25 -0
- package/lib/performance/compiler.js +52 -0
- package/lib/performance/contracts/cli.js +230 -0
- package/lib/performance/contracts/dto.js +244 -0
- package/lib/performance/contracts/git-files.js +37 -0
- package/lib/performance/contracts/graphql.js +360 -0
- package/lib/performance/contracts/openapi.js +363 -0
- package/lib/performance/db/checks.js +398 -0
- package/lib/performance/db/cli-format.js +9 -0
- package/lib/performance/db/cli-mysql.js +82 -0
- package/lib/performance/db/cli.js +469 -0
- package/lib/performance/db/drivers.js +241 -0
- package/lib/performance/db/gateway.js +194 -0
- package/lib/performance/db/hypopg.js +52 -0
- package/lib/performance/db/measure.js +141 -0
- package/lib/performance/db/mongo.js +272 -0
- package/lib/performance/db/mysql-catalog.js +64 -0
- package/lib/performance/db/pg-catalog.js +114 -0
- package/lib/performance/db/plan-estimates.js +188 -0
- package/lib/performance/db/redact.js +126 -0
- package/lib/performance/db/snapshot.js +82 -0
- package/lib/performance/dependent-writes.js +228 -0
- package/lib/performance/discarded-error-result.js +46 -0
- package/lib/performance/drizzle-write-preflight.js +195 -0
- package/lib/performance/drizzle.js +288 -0
- package/lib/performance/editor-report.js +191 -0
- package/lib/performance/editor-setup.js +189 -0
- package/lib/performance/editor-signal.js +57 -0
- package/lib/performance/editor-watch-supervisor.js +104 -0
- package/lib/performance/editor-watch.js +193 -0
- package/lib/performance/emit-options.js +29 -0
- package/lib/performance/filter-existence.js +149 -0
- package/lib/performance/find-then-create.js +281 -0
- package/lib/performance/finding-ids.js +48 -0
- package/lib/performance/finding-text.js +117 -0
- package/lib/performance/fix-cli.js +200 -0
- package/lib/performance/floating-promises.js +248 -0
- package/lib/performance/frontend-dom-perf.js +310 -0
- package/lib/performance/frontend-helpers.js +93 -0
- package/lib/performance/frontend-perf.js +472 -0
- package/lib/performance/function-kinds.js +9 -0
- package/lib/performance/guard-queries.js +356 -0
- package/lib/performance/http-timeouts.js +492 -0
- package/lib/performance/impact.js +53 -0
- package/lib/performance/index-rules-foreign-keys.js +81 -0
- package/lib/performance/index-rules-order.js +152 -0
- package/lib/performance/index-rules-pattern.js +137 -0
- package/lib/performance/index-rules-table.js +288 -0
- package/lib/performance/index-rules.js +107 -0
- package/lib/performance/json-clone.js +28 -0
- package/lib/performance/json-parse-context.js +99 -0
- package/lib/performance/last-insert-id.js +120 -0
- package/lib/performance/list-counts.js +321 -0
- package/lib/performance/list-overfetch.js +216 -0
- package/lib/performance/literal-awaits.js +190 -0
- package/lib/performance/memory-growth.js +516 -0
- package/lib/performance/migrations/cli.js +203 -0
- package/lib/performance/migrations/discover.js +354 -0
- package/lib/performance/migrations/enforce.js +177 -0
- package/lib/performance/migrations/extract-code-builders.js +291 -0
- package/lib/performance/migrations/extract-code-discovery.js +179 -0
- package/lib/performance/migrations/extract-code-sql.js +196 -0
- package/lib/performance/migrations/extract-code-types.js +1 -0
- package/lib/performance/migrations/extract-code.js +123 -0
- package/lib/performance/migrations/extract-sql.js +452 -0
- package/lib/performance/migrations/operations.js +156 -0
- package/lib/performance/migrations/postgres-registry.js +135 -0
- package/lib/performance/migrations/rules-mysql.js +105 -0
- package/lib/performance/migrations/rules-postgres-add-column.js +145 -0
- package/lib/performance/migrations/rules-postgres-shared.js +22 -0
- package/lib/performance/migrations/rules-postgres.js +464 -0
- package/lib/performance/missing-packages.js +116 -0
- package/lib/performance/models/index.js +284 -0
- package/lib/performance/mongoose-patterns.js +245 -0
- package/lib/performance/native-checker.js +312 -0
- package/lib/performance/native-runtime.js +24 -0
- package/lib/performance/native-syntax.js +132 -0
- package/lib/performance/native-workspaces.js +31 -0
- package/lib/performance/native.js +342 -0
- package/lib/performance/node-fs-context.js +390 -0
- package/lib/performance/node-fs.js +452 -0
- package/lib/performance/notification-loops.js +176 -0
- package/lib/performance/notify-editor.js +1 -0
- package/lib/performance/offset-pagination.js +166 -0
- package/lib/performance/orm-owners.js +145 -0
- package/lib/performance/orm-queries.js +496 -0
- package/lib/performance/package-types.js +57 -0
- package/lib/performance/page-counts.js +262 -0
- package/lib/performance/parallel-reads-policy.js +41 -0
- package/lib/performance/parallel-reads.js +139 -0
- package/lib/performance/password-hashing.js +218 -0
- package/lib/performance/pg-fragments.js +300 -0
- package/lib/performance/pg-integrity.js +115 -0
- package/lib/performance/phase5-rules.js +539 -0
- package/lib/performance/plans.js +283 -0
- package/lib/performance/polyglot.js +193 -0
- package/lib/performance/pooling.js +200 -0
- package/lib/performance/postgres.js +182 -0
- package/lib/performance/prisma-aggregates.js +125 -0
- package/lib/performance/prisma-integrity.js +239 -0
- package/lib/performance/prisma.js +399 -0
- package/lib/performance/projects.js +431 -0
- package/lib/performance/promise-return-escapes-catch.js +96 -0
- package/lib/performance/pure-js-hashing.js +96 -0
- package/lib/performance/query-loop-batch.js +188 -0
- package/lib/performance/query-loop-bounds.js +219 -0
- package/lib/performance/query-loop-exits.js +171 -0
- package/lib/performance/query-loop-helpers.js +42 -0
- package/lib/performance/query-loop-memo.js +81 -0
- package/lib/performance/query-loop-pagination.js +130 -0
- package/lib/performance/query-loops.js +29 -0
- package/lib/performance/query-policy.js +94 -0
- package/lib/performance/query-results.js +179 -0
- package/lib/performance/queue-loops.js +87 -0
- package/lib/performance/recursive-watch.js +181 -0
- package/lib/performance/redis-client.js +19 -0
- package/lib/performance/redis-keys.js +78 -0
- package/lib/performance/redis.js +188 -0
- package/lib/performance/redundant-indexes.js +403 -0
- package/lib/performance/reference-checks.js +22 -0
- package/lib/performance/repeated.js +200 -0
- package/lib/performance/request-handlers.js +429 -0
- package/lib/performance/request-heavy-work.js +135 -0
- package/lib/performance/request-inputs.js +303 -0
- package/lib/performance/retry-backoff.js +132 -0
- package/lib/performance/return-in-finally.js +12 -0
- package/lib/performance/return-newline.js +54 -0
- package/lib/performance/review-context.js +434 -0
- package/lib/performance/rule-ids.js +357 -0
- package/lib/performance/scan-outcome.js +37 -0
- package/lib/performance/schema/context.js +145 -0
- package/lib/performance/schema/drizzle-schema.js +278 -0
- package/lib/performance/schema/model.js +169 -0
- package/lib/performance/schema/mongoose-schema.js +189 -0
- package/lib/performance/schema/prisma-schema.js +472 -0
- package/lib/performance/schema/project-indexes-events.js +494 -0
- package/lib/performance/schema/project-indexes.js +240 -0
- package/lib/performance/schema/query-site-support.js +61 -0
- package/lib/performance/schema/query-sites-drizzle.js +220 -0
- package/lib/performance/schema/query-sites-mongoose.js +140 -0
- package/lib/performance/schema/query-sites-prisma.js +201 -0
- package/lib/performance/schema/query-sites-sequelize.js +133 -0
- package/lib/performance/schema/query-sites-typeorm.js +180 -0
- package/lib/performance/schema/query-sites.js +19 -0
- package/lib/performance/schema/raw-sql-sites.js +284 -0
- package/lib/performance/schema/sequelize-schema.js +322 -0
- package/lib/performance/schema/ts-helpers.js +130 -0
- package/lib/performance/schema/typeorm-schema.js +262 -0
- package/lib/performance/schema-tooling.js +193 -0
- package/lib/performance/scope-evidence.js +137 -0
- package/lib/performance/sequential-loops.js +557 -0
- package/lib/performance/service-call-resolution.js +54 -0
- package/lib/performance/service-loop-collections.js +263 -0
- package/lib/performance/service-loop-operations.js +235 -0
- package/lib/performance/service-loops.js +416 -0
- package/lib/performance/session-store.js +86 -0
- package/lib/performance/site-fix.js +271 -0
- package/lib/performance/site-fixes/await-before-early-exit.js +121 -0
- package/lib/performance/site-fixes/backend-mastery-fixes.js +90 -0
- package/lib/performance/site-fixes/batch-loops.js +449 -0
- package/lib/performance/site-fixes/collection-copy.js +310 -0
- package/lib/performance/site-fixes/collection-existence.js +200 -0
- package/lib/performance/site-fixes/collection-find.js +195 -0
- package/lib/performance/site-fixes/collection-helpers.js +349 -0
- package/lib/performance/site-fixes/collection-lookup-declarations.js +47 -0
- package/lib/performance/site-fixes/collection-lookups.js +101 -0
- package/lib/performance/site-fixes/collection-membership.js +124 -0
- package/lib/performance/site-fixes/collections.js +18 -0
- package/lib/performance/site-fixes/database.js +455 -0
- package/lib/performance/site-fixes/delete-preflight.js +99 -0
- package/lib/performance/site-fixes/drizzle-index.js +239 -0
- package/lib/performance/site-fixes/error-handling.js +99 -0
- package/lib/performance/site-fixes/frontend-fixes.js +193 -0
- package/lib/performance/site-fixes/guard-queries.js +172 -0
- package/lib/performance/site-fixes/helpers.js +200 -0
- package/lib/performance/site-fixes/hoisting.js +155 -0
- package/lib/performance/site-fixes/http-timeouts.js +56 -0
- package/lib/performance/site-fixes/indexes.js +454 -0
- package/lib/performance/site-fixes/integrity-drizzle.js +188 -0
- package/lib/performance/site-fixes/integrity-wrap.js +45 -0
- package/lib/performance/site-fixes/integrity.js +555 -0
- package/lib/performance/site-fixes/json-parse.js +114 -0
- package/lib/performance/site-fixes/last-insert-id.js +230 -0
- package/lib/performance/site-fixes/list-queries.js +164 -0
- package/lib/performance/site-fixes/literal-awaits.js +431 -0
- package/lib/performance/site-fixes/method-calls.js +6 -0
- package/lib/performance/site-fixes/migration-column-rules.js +208 -0
- package/lib/performance/site-fixes/migration-context.js +317 -0
- package/lib/performance/site-fixes/migration-lock-rules.js +204 -0
- package/lib/performance/site-fixes/migration-placement.js +252 -0
- package/lib/performance/site-fixes/migrations.js +34 -0
- package/lib/performance/site-fixes/page-counts.js +88 -0
- package/lib/performance/site-fixes/prisma-aggregates.js +455 -0
- package/lib/performance/site-fixes/promise-catch.js +147 -0
- package/lib/performance/site-fixes/pure-js-hashing.js +68 -0
- package/lib/performance/site-fixes/query-loop-collections.js +202 -0
- package/lib/performance/site-fixes/query-loop-lookups.js +98 -0
- package/lib/performance/site-fixes/query-loop-materialization.js +279 -0
- package/lib/performance/site-fixes/query-loop-names.js +35 -0
- package/lib/performance/site-fixes/query-loop-nodes.js +162 -0
- package/lib/performance/site-fixes/query-loop-pg-redis.js +203 -0
- package/lib/performance/site-fixes/query-loop-prisma.js +304 -0
- package/lib/performance/site-fixes/query-loop-sites.js +317 -0
- package/lib/performance/site-fixes/query-loop-typeorm.js +294 -0
- package/lib/performance/site-fixes/query-loops.js +57 -0
- package/lib/performance/site-fixes/query-shapes.js +573 -0
- package/lib/performance/site-fixes/queue-loops.js +231 -0
- package/lib/performance/site-fixes/redis-keys.js +213 -0
- package/lib/performance/site-fixes/scope-names.js +30 -0
- package/lib/performance/site-fixes/service-loop-ast.js +85 -0
- package/lib/performance/site-fixes/service-loop-callee.js +57 -0
- package/lib/performance/site-fixes/service-loop-concurrent.js +88 -0
- package/lib/performance/site-fixes/service-loop-imports.js +68 -0
- package/lib/performance/site-fixes/service-loop-read-batch.js +255 -0
- package/lib/performance/site-fixes/service-loop-siblings.js +170 -0
- package/lib/performance/site-fixes/service-loop-signature.js +33 -0
- package/lib/performance/site-fixes/service-loop-sites.js +141 -0
- package/lib/performance/site-fixes/service-loop-write-batch.js +94 -0
- package/lib/performance/site-fixes/service-loops.js +153 -0
- package/lib/performance/site-fixes/small-rewrites.js +210 -0
- package/lib/performance/site-fixes/streams.js +150 -0
- package/lib/performance/site-fixes/sync-calls.js +485 -0
- package/lib/performance/site-fixes/sync-imports.js +170 -0
- package/lib/performance/site-fixes/transaction-escape.js +40 -0
- package/lib/performance/site-fixes/transaction-io.js +280 -0
- package/lib/performance/site-fixes/typeorm-updates.js +277 -0
- package/lib/performance/site-fixes/typeorm.js +239 -0
- package/lib/performance/site-fixes/types/module-binding.js +1 -0
- package/lib/performance/site-fixes/upload-limits.js +74 -0
- package/lib/performance/site-fixes/workbook-decodes.js +254 -0
- package/lib/performance/site-fixes/writes.js +342 -0
- package/lib/performance/sort-extreme.js +142 -0
- package/lib/performance/source-inputs.js +71 -0
- package/lib/performance/source-options.js +103 -0
- package/lib/performance/source-pillars.js +23 -0
- package/lib/performance/source-text.js +59 -0
- package/lib/performance/span-timing.js +54 -0
- package/lib/performance/sql/locations.js +91 -0
- package/lib/performance/sql/mysql-tokens.js +393 -0
- package/lib/performance/sql/pg-parser.js +330 -0
- package/lib/performance/stream-errors.js +650 -0
- package/lib/performance/traces.js +363 -0
- package/lib/performance/transaction-io.js +427 -0
- package/lib/performance/typeorm-projection.js +261 -0
- package/lib/performance/typeorm-transaction-loops.js +143 -0
- package/lib/performance/typeorm-unused-count.js +36 -0
- package/lib/performance/typeorm-updates.js +268 -0
- package/lib/performance/types/ast-grep-match.js +2 -0
- package/lib/performance/types/batch-plan.js +1 -0
- package/lib/performance/types/batched-fix-input.js +1 -0
- package/lib/performance/types/call-site.js +1 -0
- package/lib/performance/types/callee-helper.js +1 -0
- package/lib/performance/types/client-family.js +1 -0
- package/lib/performance/types/collections.js +1 -0
- package/lib/performance/types/contract-findings.js +3 -0
- package/lib/performance/types/db-cli.js +1 -0
- package/lib/performance/types/db-connection.js +1 -0
- package/lib/performance/types/db-model.js +3 -0
- package/lib/performance/types/db-plan-findings.js +1 -0
- package/lib/performance/types/db-plan.js +2 -0
- package/lib/performance/types/db-snapshot.js +1 -0
- package/lib/performance/types/declaration-link.js +2 -0
- package/lib/performance/types/decorator-call.js +1 -0
- package/lib/performance/types/drizzle-query.js +1 -0
- package/lib/performance/types/editor-report.js +1 -0
- package/lib/performance/types/find-lookup-facts.js +3 -0
- package/lib/performance/types/helper-function.js +1 -0
- package/lib/performance/types/hoist-anchor.js +1 -0
- package/lib/performance/types/http-call.js +1 -0
- package/lib/performance/types/lookup-construction.js +1 -0
- package/lib/performance/types/lookup-placement.js +1 -0
- package/lib/performance/types/loop-key-site.js +1 -0
- package/lib/performance/types/loop-lookup.js +1 -0
- package/lib/performance/types/method-call.js +1 -0
- package/lib/performance/types/migration-extraction.js +1 -0
- package/lib/performance/types/migration-files.js +1 -0
- package/lib/performance/types/migration-operations.js +1 -0
- package/lib/performance/types/migrations.js +1 -0
- package/lib/performance/types/model-fallback.js +2 -0
- package/lib/performance/types/mysql-statements.js +2 -0
- package/lib/performance/types/native-modules.js +1 -0
- package/lib/performance/types/native-typescript.js +1 -0
- package/lib/performance/types/otlp-attributes.js +1 -0
- package/lib/performance/types/otlp-trace.js +1 -0
- package/lib/performance/types/page-count-pair.js +1 -0
- package/lib/performance/types/parallel-reads.js +1 -0
- package/lib/performance/types/performance-policy.js +1 -0
- package/lib/performance/types/pg-statements.js +1 -0
- package/lib/performance/types/plain-property.js +1 -0
- package/lib/performance/types/postgres-registry.js +1 -0
- package/lib/performance/types/prisma-schema.js +1 -0
- package/lib/performance/types/program-scan.js +1 -0
- package/lib/performance/types/project-indexes.js +1 -0
- package/lib/performance/types/query-loops.js +1 -0
- package/lib/performance/types/query-site.js +1 -0
- package/lib/performance/types/related-location.js +2 -0
- package/lib/performance/types/repeat-owner.js +1 -0
- package/lib/performance/types/request-handler.js +1 -0
- package/lib/performance/types/request-input.js +1 -0
- package/lib/performance/types/schema-model.js +3 -0
- package/lib/performance/types/sibling-declaration.js +1 -0
- package/lib/performance/types/source-analyzer.js +1 -0
- package/lib/performance/types/source-check-values.js +1 -0
- package/lib/performance/types/source-command.js +1 -0
- package/lib/performance/types/source-position.js +2 -0
- package/lib/performance/types/source-scan-values.js +1 -0
- package/lib/performance/types/statement-range.js +2 -0
- package/lib/performance/types/typeorm-save-shape.js +1 -0
- package/lib/performance/types/typescript-binder.js +1 -0
- package/lib/performance/types/typescript-token-lookup.js +1 -0
- package/lib/performance/types/typescript-token-position.js +1 -0
- package/lib/performance/unbounded-list-queries.js +600 -0
- package/lib/performance/unscanned-javascript.js +29 -0
- package/lib/performance/upload-limits.js +68 -0
- package/lib/performance/vendor/README.md +7 -0
- package/lib/performance/vendor/typescript/LICENSE +55 -0
- package/lib/performance/vendor/typescript/NOTICE.txt +405 -0
- package/lib/performance/vendor/typescript/dist/api/compilerOptions.generated.js +8 -0
- package/lib/performance/vendor/typescript/dist/api/diagnosticFormatter.js +169 -0
- package/lib/performance/vendor/typescript/dist/api/fs.js +70 -0
- package/lib/performance/vendor/typescript/dist/api/fsCallbacks.js +111 -0
- package/lib/performance/vendor/typescript/dist/api/node/encoder.generated.js +74 -0
- package/lib/performance/vendor/typescript/dist/api/node/encoder.js +292 -0
- package/lib/performance/vendor/typescript/dist/api/node/msgpack.js +212 -0
- package/lib/performance/vendor/typescript/dist/api/node/node.generated.js +884 -0
- package/lib/performance/vendor/typescript/dist/api/node/node.infrastructure.js +102 -0
- package/lib/performance/vendor/typescript/dist/api/node/node.js +453 -0
- package/lib/performance/vendor/typescript/dist/api/node/protocol.generated.js +241 -0
- package/lib/performance/vendor/typescript/dist/api/node/protocol.js +33 -0
- package/lib/performance/vendor/typescript/dist/api/node/wtf8.js +130 -0
- package/lib/performance/vendor/typescript/dist/api/options.js +32 -0
- package/lib/performance/vendor/typescript/dist/api/path.js +884 -0
- package/lib/performance/vendor/typescript/dist/api/prepareCompilerOptions.generated.js +24 -0
- package/lib/performance/vendor/typescript/dist/api/proto.generated.js +21 -0
- package/lib/performance/vendor/typescript/dist/api/proto.js +50 -0
- package/lib/performance/vendor/typescript/dist/api/sourceFileCache.js +300 -0
- package/lib/performance/vendor/typescript/dist/api/sync/api.js +5408 -0
- package/lib/performance/vendor/typescript/dist/api/sync/client.js +174 -0
- package/lib/performance/vendor/typescript/dist/api/sync/generatorSupport.js +338 -0
- package/lib/performance/vendor/typescript/dist/api/syncChannel.js +526 -0
- package/lib/performance/vendor/typescript/dist/api/timing.js +149 -0
- package/lib/performance/vendor/typescript/dist/api/timingDump.js +38 -0
- package/lib/performance/vendor/typescript/dist/api/userPreferences.generated.js +3 -0
- package/lib/performance/vendor/typescript/dist/ast/ast.generated.js +4 -0
- package/lib/performance/vendor/typescript/dist/ast/ast.js +8 -0
- package/lib/performance/vendor/typescript/dist/ast/astnav.js +741 -0
- package/lib/performance/vendor/typescript/dist/ast/clone.js +104 -0
- package/lib/performance/vendor/typescript/dist/ast/factory.generated.js +5751 -0
- package/lib/performance/vendor/typescript/dist/ast/index.js +25 -0
- package/lib/performance/vendor/typescript/dist/ast/is.generated.js +1400 -0
- package/lib/performance/vendor/typescript/dist/ast/is.js +456 -0
- package/lib/performance/vendor/typescript/dist/ast/jsdoc.js +208 -0
- package/lib/performance/vendor/typescript/dist/ast/modifiers.js +41 -0
- package/lib/performance/vendor/typescript/dist/ast/scanner.js +2231 -0
- package/lib/performance/vendor/typescript/dist/ast/spanMap.js +417 -0
- package/lib/performance/vendor/typescript/dist/ast/utils.js +318 -0
- package/lib/performance/vendor/typescript/dist/ast/visitor.generated.js +979 -0
- package/lib/performance/vendor/typescript/dist/ast/visitor.js +87 -0
- package/lib/performance/vendor/typescript/dist/enums/caseSensitivity.js +7 -0
- package/lib/performance/vendor/typescript/dist/enums/characterCodes.js +130 -0
- package/lib/performance/vendor/typescript/dist/enums/checkFlags.js +36 -0
- package/lib/performance/vendor/typescript/dist/enums/commentDirectiveType.js +6 -0
- package/lib/performance/vendor/typescript/dist/enums/completionItemKind.js +30 -0
- package/lib/performance/vendor/typescript/dist/enums/diagnosticCategory.js +9 -0
- package/lib/performance/vendor/typescript/dist/enums/diagnosticDirectivePolicy.js +7 -0
- package/lib/performance/vendor/typescript/dist/enums/elementFlags.js +14 -0
- package/lib/performance/vendor/typescript/dist/enums/emitOnly.js +8 -0
- package/lib/performance/vendor/typescript/dist/enums/indexKind.js +7 -0
- package/lib/performance/vendor/typescript/dist/enums/internalSymbolName.js +25 -0
- package/lib/performance/vendor/typescript/dist/enums/jsDeclarationKind.js +12 -0
- package/lib/performance/vendor/typescript/dist/enums/jsxEmit.js +11 -0
- package/lib/performance/vendor/typescript/dist/enums/languageVariant.js +6 -0
- package/lib/performance/vendor/typescript/dist/enums/modifierFlags.js +44 -0
- package/lib/performance/vendor/typescript/dist/enums/moduleDetectionKind.js +9 -0
- package/lib/performance/vendor/typescript/dist/enums/moduleKind.js +19 -0
- package/lib/performance/vendor/typescript/dist/enums/moduleResolutionKind.js +11 -0
- package/lib/performance/vendor/typescript/dist/enums/newLineKind.js +8 -0
- package/lib/performance/vendor/typescript/dist/enums/nodeBuilderFlags.js +38 -0
- package/lib/performance/vendor/typescript/dist/enums/nodeFlags.js +46 -0
- package/lib/performance/vendor/typescript/dist/enums/objectFlags.js +53 -0
- package/lib/performance/vendor/typescript/dist/enums/outerExpressionKinds.js +18 -0
- package/lib/performance/vendor/typescript/dist/enums/regularExpressionFlags.js +14 -0
- package/lib/performance/vendor/typescript/dist/enums/scriptKind.js +11 -0
- package/lib/performance/vendor/typescript/dist/enums/scriptTarget.js +20 -0
- package/lib/performance/vendor/typescript/dist/enums/signatureFlags.js +17 -0
- package/lib/performance/vendor/typescript/dist/enums/signatureKind.js +7 -0
- package/lib/performance/vendor/typescript/dist/enums/spanMapFeature.js +27 -0
- package/lib/performance/vendor/typescript/dist/enums/spanMapFidelity.js +9 -0
- package/lib/performance/vendor/typescript/dist/enums/spanMapKind.js +8 -0
- package/lib/performance/vendor/typescript/dist/enums/symbolFlags.js +72 -0
- package/lib/performance/vendor/typescript/dist/enums/symbolOwnerKind.js +7 -0
- package/lib/performance/vendor/typescript/dist/enums/syntaxKind.js +392 -0
- package/lib/performance/vendor/typescript/dist/enums/tokenFlags.js +32 -0
- package/lib/performance/vendor/typescript/dist/enums/typeFlags.js +78 -0
- package/lib/performance/vendor/typescript/dist/enums/typeFormatFlags.js +31 -0
- package/lib/performance/vendor/typescript/dist/enums/typePredicateKind.js +9 -0
- package/lib/performance/vendor/typescript/dist/internal/utils.js +25 -0
- package/lib/performance/vendor/typescript/lib/getExePath.js +70 -0
- package/lib/performance/vendor/typescript/package.json +93 -0
- package/lib/performance/vendor/typescript/vendor/vscode-jsonrpc/License.txt +11 -0
- package/lib/performance/watch.js +99 -0
- package/lib/performance/workbook-decodes.js +147 -0
- package/lib/reliability/analyze.js +29 -0
- package/lib/reliability/boundary-access.js +521 -0
- package/lib/reliability/cli.js +20 -0
- package/lib/reliability/resource-leaks.js +526 -0
- package/lib/reliability/rule-ids.js +225 -0
- package/lib/reliability/site-fixes/boundary-access.js +80 -0
- package/lib/reliability/site-fixes/resource-leaks.js +125 -0
- package/lib/reliability/site-fixes/suspicious-logic.js +115 -0
- package/lib/reliability/source-helpers.js +32 -0
- package/lib/reliability/sql-insert-terminator.js +106 -0
- package/lib/reliability/standalone-sources.js +54 -0
- package/lib/reliability/suspicious-logic.js +364 -0
- package/lib/reliability/swallowed-errors.js +321 -0
- package/lib/reliability/usage.js +16 -0
- package/lib/reliability/walk.js +16 -0
- package/lib/security/analyze.js +129 -0
- package/lib/security/auth-crypto/comparison.js +97 -0
- package/lib/security/auth-crypto/hashing.js +302 -0
- package/lib/security/auth-crypto/index.js +32 -0
- package/lib/security/auth-crypto/jwt.js +468 -0
- package/lib/security/auth-crypto/plaintext-password.js +171 -0
- package/lib/security/auth-crypto/random.js +124 -0
- package/lib/security/auth-crypto/rate-limits.js +326 -0
- package/lib/security/auth-crypto/rule-ids.js +17 -0
- package/lib/security/auth-crypto/secrets.js +331 -0
- package/lib/security/auth-crypto/shared.js +105 -0
- package/lib/security/auth-crypto/transport-and-ciphers.js +217 -0
- package/lib/security/bindings.js +286 -0
- package/lib/security/cli.js +293 -0
- package/lib/security/declarations.js +25 -0
- package/lib/security/deps/advisory.js +142 -0
- package/lib/security/deps/cli.js +75 -0
- package/lib/security/deps/lockfiles.js +310 -0
- package/lib/security/deps/osv.js +217 -0
- package/lib/security/deps/rule-ids.js +6 -0
- package/lib/security/deps/scan.js +69 -0
- package/lib/security/examples/auth-crypto.cjs +57 -0
- package/lib/security/examples/deps.cjs +9 -0
- package/lib/security/examples/exposure.cjs +98 -0
- package/lib/security/examples/files.cjs +29 -0
- package/lib/security/examples/injection.cjs +53 -0
- package/lib/security/examples/moved.cjs +17 -0
- package/lib/security/examples/request-forgery.cjs +25 -0
- package/lib/security/exposure/backend-security-mastery.js +80 -0
- package/lib/security/exposure/cookies.js +173 -0
- package/lib/security/exposure/cors-origin-regex.js +177 -0
- package/lib/security/exposure/cors.js +217 -0
- package/lib/security/exposure/error-responses.js +437 -0
- package/lib/security/exposure/frontend-security.js +547 -0
- package/lib/security/exposure/graphql.js +131 -0
- package/lib/security/exposure/index.js +52 -0
- package/lib/security/exposure/literals.js +133 -0
- package/lib/security/exposure/logging.js +168 -0
- package/lib/security/exposure/mass-assignment.js +165 -0
- package/lib/security/exposure/password-response.js +315 -0
- package/lib/security/exposure/prototype-pollution.js +291 -0
- package/lib/security/exposure/reflected-xss.js +57 -0
- package/lib/security/exposure/report.js +10 -0
- package/lib/security/exposure/rule-ids.js +28 -0
- package/lib/security/exposure/storage-acl.js +87 -0
- package/lib/security/exposure/template-autoescape.js +39 -0
- package/lib/security/exposure/url-secrets.js +164 -0
- package/lib/security/exposure/validation-pipe.js +36 -0
- package/lib/security/exposure/xml.js +28 -0
- package/lib/security/file-context.js +82 -0
- package/lib/security/files/compose.js +79 -0
- package/lib/security/files/dockerfile.js +206 -0
- package/lib/security/files/index.js +100 -0
- package/lib/security/files/project-files.js +103 -0
- package/lib/security/files/review-directive.js +30 -0
- package/lib/security/files/rule-ids.js +10 -0
- package/lib/security/files/secret-values.js +98 -0
- package/lib/security/files/secrets.js +121 -0
- package/lib/security/injection/code.js +108 -0
- package/lib/security/injection/command.js +127 -0
- package/lib/security/injection/index.js +13 -0
- package/lib/security/injection/nosql.js +266 -0
- package/lib/security/injection/redos.js +609 -0
- package/lib/security/injection/regex.js +48 -0
- package/lib/security/injection/rule-ids.js +16 -0
- package/lib/security/injection/shared.js +119 -0
- package/lib/security/injection/sql.js +432 -0
- package/lib/security/pg-dynamic-query.js +30 -0
- package/lib/security/pg-identifier-guards.js +155 -0
- package/lib/security/phase5-rules.js +515 -0
- package/lib/security/polyglot.js +8 -0
- package/lib/security/request-forgery/index.js +11 -0
- package/lib/security/request-forgery/open-redirect.js +336 -0
- package/lib/security/request-forgery/path-traversal.js +103 -0
- package/lib/security/request-forgery/rule-ids.js +9 -0
- package/lib/security/request-forgery/shared.js +355 -0
- package/lib/security/request-forgery/ssrf.js +133 -0
- package/lib/security/request-forgery/upload-filename.js +75 -0
- package/lib/security/request-forgery/zip-slip.js +42 -0
- package/lib/security/rule-descriptions.js +84 -0
- package/lib/security/rule-ids.js +142 -0
- package/lib/security/scope/drizzle-policy.js +197 -0
- package/lib/security/scope/query-policy.js +156 -0
- package/lib/security/site-fixes/auth-crypto.js +223 -0
- package/lib/security/site-fixes/backend-security-fixes.js +86 -0
- package/lib/security/site-fixes/error-responses.js +84 -0
- package/lib/security/site-fixes/exposure.js +120 -0
- package/lib/security/site-fixes/files.js +45 -0
- package/lib/security/site-fixes/frontend-security-fixes.js +73 -0
- package/lib/security/site-fixes/injection.js +119 -0
- package/lib/security/site-fixes/jwt.js +89 -0
- package/lib/security/site-fixes/list-edits.js +16 -0
- package/lib/security/site-fixes/request-forgery.js +117 -0
- package/lib/security/site-fixes/secret-comparison.js +107 -0
- package/lib/security/site-fixes/template-autoescape.js +25 -0
- package/lib/security/taint/archive-sources.js +127 -0
- package/lib/security/taint/filename-guard.js +110 -0
- package/lib/security/taint/guards.js +274 -0
- package/lib/security/taint/index.js +559 -0
- package/lib/security/taint/propagate.js +117 -0
- package/lib/security/taint/sanitizers.js +67 -0
- package/lib/security/taint/sources.js +357 -0
- package/lib/security/taint/summaries.js +207 -0
- package/lib/security/taint/url-parts.js +264 -0
- package/lib/security/taint/validators.js +420 -0
- package/lib/security/types/condition-guards.js +1 -0
- package/lib/security/types/file-finding.js +1 -0
- package/lib/security/types/inspectable-type.js +1 -0
- package/lib/security/types/lockfile.js +1 -0
- package/lib/security/types/osv-vulnerability.js +1 -0
- package/lib/security/types/project-files.js +1 -0
- package/lib/security/types/propagation.js +1 -0
- package/lib/security/types/rule-example.js +1 -0
- package/lib/security/types/schema-call.js +1 -0
- package/lib/security/types/security-check.js +1 -0
- package/lib/shared/agent-init.js +235 -0
- package/lib/shared/agent-session.js +28 -0
- package/lib/shared/agent-verify.js +239 -0
- package/lib/shared/atomic-write.js +52 -0
- package/lib/shared/baseline-flags.js +33 -0
- package/lib/shared/baseline.js +237 -0
- package/lib/shared/build-output.js +22 -0
- package/lib/shared/check.js +247 -0
- package/lib/shared/config.js +286 -0
- package/lib/shared/coverage-notes.js +27 -0
- package/lib/shared/error-code.js +9 -0
- package/lib/shared/execution-context.js +278 -0
- package/lib/shared/explain.js +34 -0
- package/lib/shared/fix-command.js +23 -0
- package/lib/shared/fix-convergence.js +389 -0
- package/lib/shared/fix-handoff.js +57 -0
- package/lib/shared/fix-history.js +303 -0
- package/lib/shared/fix-hunks.js +108 -0
- package/lib/shared/fix-imports.js +233 -0
- package/lib/shared/fix-presentation-comments.js +253 -0
- package/lib/shared/fix-presentation-prettier.js +233 -0
- package/lib/shared/fix-presentation-rows.js +157 -0
- package/lib/shared/fix-presentation-style.js +230 -0
- package/lib/shared/fix-presentation.js +177 -0
- package/lib/shared/fix-rationales.js +151 -0
- package/lib/shared/fix-recipes.js +101 -0
- package/lib/shared/fix-safety.js +64 -0
- package/lib/shared/fix-terminal.js +65 -0
- package/lib/shared/fix-typecheck.js +188 -0
- package/lib/shared/fix.js +257 -0
- package/lib/shared/formats/contract-rules.js +9 -0
- package/lib/shared/formats/finding-location.js +31 -0
- package/lib/shared/formats/github.js +36 -0
- package/lib/shared/formats/index.js +29 -0
- package/lib/shared/formats/sarif.js +91 -0
- package/lib/shared/function-summaries.js +571 -0
- package/lib/shared/function-syntax.js +86 -0
- package/lib/shared/git-hook.js +153 -0
- package/lib/shared/git-paths.js +38 -0
- package/lib/shared/glob.js +53 -0
- package/lib/shared/heap-limit.js +60 -0
- package/lib/shared/hot-path-graph.js +268 -0
- package/lib/shared/hot-path.js +20 -0
- package/lib/shared/impact-levels.js +49 -0
- package/lib/shared/is-record.js +5 -0
- package/lib/shared/managed-blocks.js +54 -0
- package/lib/shared/notify-editor.js +50 -0
- package/lib/shared/pending-review.js +117 -0
- package/lib/shared/pillar-rules.js +6 -0
- package/lib/shared/pillars.js +384 -0
- package/lib/shared/polyglot-compatibility.js +105 -0
- package/lib/shared/project-root.js +35 -0
- package/lib/shared/real-target.js +23 -0
- package/lib/shared/reason-groups.js +20 -0
- package/lib/shared/review-delivery.js +33 -0
- package/lib/shared/review-mcp.js +262 -0
- package/lib/shared/review-request.js +59 -0
- package/lib/shared/rule-registry.js +57 -0
- package/lib/shared/scan-cache.js +234 -0
- package/lib/shared/shell-argument.js +9 -0
- package/lib/shared/source-report.js +156 -0
- package/lib/shared/types/baseline.js +1 -0
- package/lib/shared/types/checker-run.js +1 -0
- package/lib/shared/types/cli-finding.js +1 -0
- package/lib/shared/types/fix-hunks.js +1 -0
- package/lib/shared/types/fix-presentation.js +1 -0
- package/lib/shared/types/fix-run.js +1 -0
- package/lib/shared/types/function-summaries.js +1 -0
- package/lib/shared/types/managed-blocks.js +1 -0
- package/lib/shared/types/pillar-name.js +1 -0
- package/lib/shared/types/report-formats.js +1 -0
- package/lib/shared/types/review-event.js +1 -0
- package/lib/shared/types/review-history.js +1 -0
- package/lib/shared/types/settings.js +1 -0
- package/lib/shared/types/source-report.js +1 -0
- package/lib/shared/types/typescript-assignment-target.js +1 -0
- package/lib/shared/types/typescript-internals.js +1 -0
- package/lib/shared/types/typescript-module-resolution.js +1 -0
- package/lib/shared/types/typescript-outer-expression.js +1 -0
- package/lib/shared/types.js +1 -0
- package/lib/shared/workspaces.js +299 -0
- package/package.json +127 -4
- package/plugin/.claude-plugin/plugin.json +9 -0
- package/plugin/commands/loadwise.md +24 -0
- package/plugin/hooks/check-edited-file.js +142 -0
- package/plugin/hooks/hooks.json +17 -0
- package/polyglot/maintainability/rules.js +159 -0
- package/polyglot/maintainability/sgconfig.yml +12 -0
- package/polyglot/performance/rules/csharp.yml +104 -0
- package/polyglot/performance/rules/go.yml +123 -0
- package/polyglot/performance/rules/input.yml +37 -0
- package/polyglot/performance/rules/java.yml +115 -0
- package/polyglot/performance/rules/python.yml +159 -0
- package/polyglot/performance/rules/rust.yml +88 -0
- package/polyglot/performance/sgconfig.yml +8 -0
- package/polyglot/reliability/rules/csharp.yml +65 -0
- package/polyglot/reliability/rules/go.yml +76 -0
- package/polyglot/reliability/rules/java.yml +41 -0
- package/polyglot/reliability/rules/python.yml +32 -0
- package/polyglot/reliability/rules/rust.yml +34 -0
- package/polyglot/reliability/sgconfig.yml +8 -0
- package/polyglot/security/rules/csharp.yml +28 -0
- package/polyglot/security/rules/go.yml +42 -0
- package/polyglot/security/rules/java.yml +17 -0
- package/polyglot/security/rules/python.yml +48 -0
- package/polyglot/security/rules/rust.yml +23 -0
- package/polyglot/security/sgconfig.yml +8 -0
- package/schema/loadwise.config.schema.json +725 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
// Rules about code that crashes, loses data or silently misbehaves at runtime: unhandled async failures, error
|
|
2
|
+
// handling, races and integrity, external-call resilience, migration lock and outage risks, and breaking API changes.
|
|
3
|
+
// The source rules are reported by the shared TypeScript pass; migrations and contracts by their own subcommands.
|
|
4
|
+
const sourceRules = [
|
|
5
|
+
'pg-transaction-on-pool',
|
|
6
|
+
'prisma-transaction-client-escape',
|
|
7
|
+
'prisma-read-modify-write',
|
|
8
|
+
'prisma-dependent-writes',
|
|
9
|
+
'drizzle-unfiltered-write',
|
|
10
|
+
'http-call-without-timeout',
|
|
11
|
+
'upload-without-size-limit',
|
|
12
|
+
'mongoose-aggregate-uncast-id',
|
|
13
|
+
'typeorm-transaction-client-escape',
|
|
14
|
+
'redis-incr-then-expire',
|
|
15
|
+
'floating-promise',
|
|
16
|
+
'discarded-error-result',
|
|
17
|
+
'promise-return-escapes-catch',
|
|
18
|
+
'return-in-finally',
|
|
19
|
+
'return-newline',
|
|
20
|
+
'drizzle-write-preflight',
|
|
21
|
+
'find-then-create-race',
|
|
22
|
+
'retry-without-backoff',
|
|
23
|
+
'async-route-unhandled-rejection',
|
|
24
|
+
'async-callback-unhandled-rejection',
|
|
25
|
+
'stream-pipe-unhandled-error',
|
|
26
|
+
'json-parse-unguarded',
|
|
27
|
+
'request-number-unvalidated',
|
|
28
|
+
'check-then-update-race',
|
|
29
|
+
'payment-missing-idempotency-key',
|
|
30
|
+
'webhook-missing-idempotency-check',
|
|
31
|
+
'unbounded-promise-all',
|
|
32
|
+
'swallowed-error',
|
|
33
|
+
'sql-insert-truncated-at-semicolon',
|
|
34
|
+
'unguarded-boundary-access',
|
|
35
|
+
'assignment-in-condition',
|
|
36
|
+
'nan-comparison',
|
|
37
|
+
'invalid-typeof-comparison',
|
|
38
|
+
'unreachable-code',
|
|
39
|
+
'loop-index-past-length',
|
|
40
|
+
'file-handle-not-closed',
|
|
41
|
+
'query-runner-not-released',
|
|
42
|
+
'browser-not-closed',
|
|
43
|
+
'interval-not-cleared',
|
|
44
|
+
];
|
|
45
|
+
const migrationRules = [
|
|
46
|
+
'migration-index-not-concurrent',
|
|
47
|
+
'migration-concurrent-in-transaction',
|
|
48
|
+
'migration-not-null-without-default',
|
|
49
|
+
'migration-volatile-default',
|
|
50
|
+
'migration-column-type-rewrite',
|
|
51
|
+
'migration-set-not-null-scan',
|
|
52
|
+
'migration-constraint-not-valid',
|
|
53
|
+
'migration-constraint-without-index',
|
|
54
|
+
'migration-breaking-drop',
|
|
55
|
+
'migration-breaking-rename',
|
|
56
|
+
'migration-missing-lock-timeout',
|
|
57
|
+
'migration-table-rewrite-command',
|
|
58
|
+
'migration-unparsed',
|
|
59
|
+
'migration-mysql-table-copy',
|
|
60
|
+
'migration-mysql-lock-unspecified',
|
|
61
|
+
];
|
|
62
|
+
const contractRules = [
|
|
63
|
+
'api-removed-operation',
|
|
64
|
+
'api-removed-field',
|
|
65
|
+
'api-required-input',
|
|
66
|
+
'api-type-changed',
|
|
67
|
+
'api-enum-value-removed',
|
|
68
|
+
];
|
|
69
|
+
// Rules the ast-grep polyglot scan reports from polyglot/reliability.
|
|
70
|
+
const polyglotRules = [
|
|
71
|
+
'csharp-async-void',
|
|
72
|
+
'csharp-disposable-without-using',
|
|
73
|
+
'python-bare-except',
|
|
74
|
+
'python-swallowed-exception',
|
|
75
|
+
'go-error-discarded',
|
|
76
|
+
'go-defer-before-error-check',
|
|
77
|
+
'java-resource-without-try',
|
|
78
|
+
'rust-unwrap-in-production',
|
|
79
|
+
];
|
|
80
|
+
// One --ignore list is shared by every command, so a CI script can pass the same flags to each of them.
|
|
81
|
+
const knownRules = new Set([...sourceRules, ...migrationRules, ...contractRules]);
|
|
82
|
+
// Impact levels (see lib/shared/impact-levels.ts) for every rule id a reliability finding can carry. README criteria:
|
|
83
|
+
// critical is data loss, an outage or a lock risk in production; high a crash, lost failure or race that a normal
|
|
84
|
+
// request can hit; medium a failure that needs an unusual input or condition; low a hygiene issue.
|
|
85
|
+
const impactByRule = {
|
|
86
|
+
'pg-transaction-on-pool': 'critical',
|
|
87
|
+
'prisma-transaction-client-escape': 'critical',
|
|
88
|
+
'typeorm-transaction-client-escape': 'critical',
|
|
89
|
+
'prisma-read-modify-write': 'critical',
|
|
90
|
+
'drizzle-unfiltered-write': 'critical',
|
|
91
|
+
'migration-index-not-concurrent': 'critical',
|
|
92
|
+
'migration-breaking-drop': 'critical',
|
|
93
|
+
'migration-column-type-rewrite': 'critical',
|
|
94
|
+
'migration-table-rewrite-command': 'critical',
|
|
95
|
+
'migration-mysql-table-copy': 'critical',
|
|
96
|
+
'api-removed-operation': 'critical',
|
|
97
|
+
'prisma-dependent-writes': 'high',
|
|
98
|
+
'find-then-create-race': 'high',
|
|
99
|
+
'floating-promise': 'high',
|
|
100
|
+
'discarded-error-result': 'high',
|
|
101
|
+
'promise-return-escapes-catch': 'high',
|
|
102
|
+
'return-in-finally': 'high',
|
|
103
|
+
'return-newline': 'high',
|
|
104
|
+
'drizzle-write-preflight': 'medium',
|
|
105
|
+
'http-call-without-timeout': 'high',
|
|
106
|
+
'upload-without-size-limit': 'high',
|
|
107
|
+
'mongoose-aggregate-uncast-id': 'high',
|
|
108
|
+
'check-then-update-race': 'high',
|
|
109
|
+
'payment-missing-idempotency-key': 'high',
|
|
110
|
+
'webhook-missing-idempotency-check': 'medium',
|
|
111
|
+
'redis-incr-then-expire': 'medium',
|
|
112
|
+
'retry-without-backoff': 'medium',
|
|
113
|
+
'async-route-unhandled-rejection': 'high',
|
|
114
|
+
'async-callback-unhandled-rejection': 'high',
|
|
115
|
+
'stream-pipe-unhandled-error': 'high',
|
|
116
|
+
'json-parse-unguarded': 'medium',
|
|
117
|
+
'request-number-unvalidated': 'medium',
|
|
118
|
+
'migration-concurrent-in-transaction': 'high',
|
|
119
|
+
'migration-not-null-without-default': 'high',
|
|
120
|
+
'migration-volatile-default': 'high',
|
|
121
|
+
'migration-set-not-null-scan': 'high',
|
|
122
|
+
'migration-constraint-not-valid': 'high',
|
|
123
|
+
'migration-constraint-without-index': 'high',
|
|
124
|
+
'migration-breaking-rename': 'high',
|
|
125
|
+
'migration-missing-lock-timeout': 'high',
|
|
126
|
+
'migration-mysql-lock-unspecified': 'high',
|
|
127
|
+
'api-removed-field': 'high',
|
|
128
|
+
'api-required-input': 'high',
|
|
129
|
+
'api-type-changed': 'high',
|
|
130
|
+
'api-enum-value-removed': 'high',
|
|
131
|
+
'migration-unparsed': 'low',
|
|
132
|
+
'unbounded-promise-all': 'high',
|
|
133
|
+
'csharp-async-void': 'high',
|
|
134
|
+
'sql-insert-truncated-at-semicolon': 'high',
|
|
135
|
+
'swallowed-error': 'medium',
|
|
136
|
+
'unguarded-boundary-access': 'medium',
|
|
137
|
+
'assignment-in-condition': 'high',
|
|
138
|
+
'nan-comparison': 'high',
|
|
139
|
+
'invalid-typeof-comparison': 'high',
|
|
140
|
+
'unreachable-code': 'medium',
|
|
141
|
+
'loop-index-past-length': 'high',
|
|
142
|
+
'file-handle-not-closed': 'high',
|
|
143
|
+
'query-runner-not-released': 'critical',
|
|
144
|
+
'browser-not-closed': 'high',
|
|
145
|
+
'interval-not-cleared': 'medium',
|
|
146
|
+
'csharp-disposable-without-using': 'medium',
|
|
147
|
+
'python-bare-except': 'medium',
|
|
148
|
+
'python-swallowed-exception': 'medium',
|
|
149
|
+
'go-error-discarded': 'high',
|
|
150
|
+
'go-defer-before-error-check': 'high',
|
|
151
|
+
'java-resource-without-try': 'high',
|
|
152
|
+
'rust-unwrap-in-production': 'medium',
|
|
153
|
+
};
|
|
154
|
+
// One-line summaries of every rule above, used where a rule needs a fixed name (SARIF shortDescription) rather than
|
|
155
|
+
// the per-site finding message. The README row for each rule has the full evidence.
|
|
156
|
+
const descriptionByRule = {
|
|
157
|
+
'api-enum-value-removed': 'An enum value or string-literal option that clients could send was removed.',
|
|
158
|
+
'api-removed-field': 'A response field, GraphQL type, field, argument or union member, or returned DTO property was removed.',
|
|
159
|
+
'api-removed-operation': 'An OpenAPI operation or a GraphQL Query, Mutation or Subscription field was removed.',
|
|
160
|
+
'api-required-input': 'A request field, parameter or GraphQL argument is new and required, or became required.',
|
|
161
|
+
'api-type-changed': 'A field or parameter changed type, or a GraphQL type changed nullability in a breaking direction.',
|
|
162
|
+
'drizzle-unfiltered-write': 'A Drizzle update or delete executes without an effective where clause.',
|
|
163
|
+
'find-then-create-race': 'A lookup by key is followed by an insert with that key, with no unique constraint to stop duplicates.',
|
|
164
|
+
'floating-promise': 'A promise-returning call is neither awaited, returned nor handled, so its failure goes unseen.',
|
|
165
|
+
'discarded-error-result': 'A call discards a typed Either or Result that can carry a failure as a value.',
|
|
166
|
+
'promise-return-escapes-catch': 'Returning a promise directly from a protected try block can bypass its catch on rejection.',
|
|
167
|
+
'return-in-finally': 'Returning from finally can replace a pending return value or suppress a thrown error.',
|
|
168
|
+
'return-newline': 'A line break after return ends the statement before the apparent return value.',
|
|
169
|
+
'drizzle-write-preflight': 'A separate existence check before a Drizzle write can race with another request.',
|
|
170
|
+
'http-call-without-timeout': 'A fetch or axios call has no timeout or abort signal.',
|
|
171
|
+
'migration-breaking-drop': 'A migration drops a column or table that running code may still use.',
|
|
172
|
+
'migration-breaking-rename': 'A migration renames a column or table that running code may still use.',
|
|
173
|
+
'migration-column-type-rewrite': 'A migration changes a column type in a way that rewrites the table.',
|
|
174
|
+
'migration-concurrent-in-transaction': 'A CONCURRENTLY index statement runs inside a transaction, where PostgreSQL rejects it.',
|
|
175
|
+
'migration-constraint-not-valid': 'A constraint is added and validated in one step instead of NOT VALID first.',
|
|
176
|
+
'migration-constraint-without-index': 'A unique or primary key constraint builds its index while blocking writes.',
|
|
177
|
+
'migration-index-not-concurrent': 'A PostgreSQL index is built without CONCURRENTLY, blocking writes to the table.',
|
|
178
|
+
'migration-missing-lock-timeout': 'A migration statement takes a lock with no lock_timeout set.',
|
|
179
|
+
'migration-mysql-lock-unspecified': 'A MySQL ALTER does not state its LOCK level.',
|
|
180
|
+
'migration-mysql-table-copy': 'A MySQL ALTER copies the whole table.',
|
|
181
|
+
'migration-not-null-without-default': 'A NOT NULL column is added without a default, which fails once rows exist.',
|
|
182
|
+
'migration-set-not-null-scan': 'SET NOT NULL scans the whole table while holding a lock.',
|
|
183
|
+
'migration-table-rewrite-command': 'A migration runs VACUUM FULL, CLUSTER or REINDEX, which rewrites or locks the table.',
|
|
184
|
+
'migration-unparsed': 'A migration statement could not be parsed and needs a manual review.',
|
|
185
|
+
'migration-volatile-default': 'A column is added with a volatile default, which rewrites the table.',
|
|
186
|
+
'pg-transaction-on-pool': 'A transaction statement is sent to a pool, so its statements can run on different connections.',
|
|
187
|
+
'prisma-dependent-writes': 'Adjacent Prisma creates pass a value from the first record into the next write.',
|
|
188
|
+
'prisma-read-modify-write': 'A Prisma read feeds a numeric update of the same row, losing concurrent updates.',
|
|
189
|
+
'prisma-transaction-client-escape': 'A Prisma call inside an interactive transaction uses the outer client instead of the transaction client.',
|
|
190
|
+
'redis-incr-then-expire': 'A Redis counter increment and its expire on the same key are two round trips and not atomic.',
|
|
191
|
+
'retry-without-backoff': 'A retry loop calls the network again with no delay between attempts.',
|
|
192
|
+
'async-route-unhandled-rejection': 'An Express 4 async route handler has no error handling, so a rejection never reaches the error middleware.',
|
|
193
|
+
'async-callback-unhandled-rejection': 'An async callback given to an event emitter, timer or scheduler has no error handling, so a rejection is unhandled.',
|
|
194
|
+
'stream-pipe-unhandled-error': 'A stream is piped with .pipe() and no error handling, so a stream error can crash the process or leak the file.',
|
|
195
|
+
'json-parse-unguarded': 'JSON.parse runs on outside input with no try/catch, so malformed input throws where it is not handled.',
|
|
196
|
+
'request-number-unvalidated': 'A number parsed from request input reaches a query or calculation with no NaN or range check.',
|
|
197
|
+
'typeorm-transaction-client-escape': 'A write inside a TypeORM transaction goes through a repository not bound to it.',
|
|
198
|
+
'upload-without-size-limit': 'A multer or Nest upload interceptor has no file size limit.',
|
|
199
|
+
'mongoose-aggregate-uncast-id': 'A Mongoose aggregate $match compares _id to an uncast string instead of an ObjectId.',
|
|
200
|
+
'check-then-update-race': "A Mongoose or Sequelize document's numeric field is read, changed in JavaScript and saved without a transaction, losing concurrent updates.",
|
|
201
|
+
'payment-missing-idempotency-key': 'A Stripe call that moves money has no idempotency key, so a retry can charge or pay out twice.',
|
|
202
|
+
'webhook-missing-idempotency-check': 'A webhook route inserts rows without first checking whether the event was already processed.',
|
|
203
|
+
'unbounded-promise-all': 'Promise.all runs over an unbounded collection without a concurrency limit, risking memory spikes or downstream saturation.',
|
|
204
|
+
'csharp-async-void': 'An async void method cannot be awaited and can crash the process on unhandled exceptions.',
|
|
205
|
+
'sql-insert-truncated-at-semicolon': 'A SQL dump parser ends INSERT values at a semicolon inside quoted text.',
|
|
206
|
+
'swallowed-error': 'A catch block drops the error and the code after the try carries on as if it succeeded.',
|
|
207
|
+
'unguarded-boundary-access': 'A nested property is read from outside input or a lookup that can be missing, so absent data throws a TypeError.',
|
|
208
|
+
'assignment-in-condition': 'A condition assigns with = where a comparison was probably meant.',
|
|
209
|
+
'nan-comparison': 'A value is compared to NaN with an equality operator, which is never true.',
|
|
210
|
+
'invalid-typeof-comparison': 'A typeof result is compared to a string typeof never returns, so the check never matches.',
|
|
211
|
+
'unreachable-code': 'Statements follow a return, throw, break or continue in the same block and never run.',
|
|
212
|
+
'loop-index-past-length': 'A loop runs its index up to and including length, so the last pass reads past the end.',
|
|
213
|
+
'file-handle-not-closed': 'A FileHandle from fs/promises open() is not closed on every path, leaking a file descriptor.',
|
|
214
|
+
'query-runner-not-released': 'A TypeORM QueryRunner is not released in a finally block, so an error leaks its pooled connection.',
|
|
215
|
+
'browser-not-closed': 'A Playwright or Puppeteer browser is not closed in a finally block, so an error leaves the process running.',
|
|
216
|
+
'interval-not-cleared': 'A setInterval handle is discarded or never cleared, so the timer outlives its owner.',
|
|
217
|
+
'csharp-disposable-without-using': 'A C# stream, connection or other IDisposable is created without using, so an exception leaks it.',
|
|
218
|
+
'python-bare-except': 'A bare except also catches SystemExit and KeyboardInterrupt, hiding shutdowns and bugs.',
|
|
219
|
+
'python-swallowed-exception': 'A Python except block only passes, so the failure is dropped silently.',
|
|
220
|
+
'go-error-discarded': 'A Go error result is assigned to the blank identifier and never checked.',
|
|
221
|
+
'go-defer-before-error-check': 'A Go defer closes a resource before its error is checked, so a failed open dereferences nil.',
|
|
222
|
+
'java-resource-without-try': 'A Java stream, reader or connection is opened outside try-with-resources, so an exception leaks it.',
|
|
223
|
+
'rust-unwrap-in-production': 'Rust code outside tests calls unwrap(), turning an Err or None into a panic.',
|
|
224
|
+
};
|
|
225
|
+
export { sourceRules, migrationRules, contractRules, polyglotRules, knownRules, impactByRule, descriptionByRule };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ts } from '../../performance/compiler.js';
|
|
2
|
+
import { isAccess, isAssignmentOperator } from '../source-helpers.js';
|
|
3
|
+
const note = 'The read now yields undefined instead of throwing when the value is missing, and that undefined flows on to the caller. ' +
|
|
4
|
+
'Add a `?? default` where a value is needed, or answer with a 400 when the input is required.';
|
|
5
|
+
// The finding points at the property name (or the bracket argument) of the read.
|
|
6
|
+
function reportedAccess(node) {
|
|
7
|
+
return ts.findAncestor(node, (candidate) => {
|
|
8
|
+
if (ts.isPropertyAccessExpression(candidate))
|
|
9
|
+
return candidate.name === node;
|
|
10
|
+
return (ts.isElementAccessExpression(candidate) &&
|
|
11
|
+
ts.findAncestor(node, (inner) => inner === candidate.argumentExpression) !== undefined);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
// Whether `parent` is a step on the way from a destructuring target up to the pattern that holds it.
|
|
15
|
+
function isPatternStep(parent, child) {
|
|
16
|
+
return (ts.isParenthesizedExpression(parent) ||
|
|
17
|
+
ts.isArrayLiteralExpression(parent) ||
|
|
18
|
+
ts.isObjectLiteralExpression(parent) ||
|
|
19
|
+
ts.isSpreadElement(parent) ||
|
|
20
|
+
ts.isSpreadAssignment(parent) ||
|
|
21
|
+
(ts.isPropertyAssignment(parent) && parent.initializer === child));
|
|
22
|
+
}
|
|
23
|
+
// `[req.body.a.b] = list`, `({ key: req.body.a.b } = source)` and `({ ...req.body.a.b } = source)` write to
|
|
24
|
+
// the access although it sits inside an array or object literal.
|
|
25
|
+
function isDestructuringTarget(node) {
|
|
26
|
+
let current = node;
|
|
27
|
+
let insideLiteral = false;
|
|
28
|
+
while (isPatternStep(current.parent, current)) {
|
|
29
|
+
current = current.parent;
|
|
30
|
+
if (ts.isArrayLiteralExpression(current) || ts.isObjectLiteralExpression(current))
|
|
31
|
+
insideLiteral = true;
|
|
32
|
+
}
|
|
33
|
+
if (!insideLiteral)
|
|
34
|
+
return false;
|
|
35
|
+
const parent = current.parent;
|
|
36
|
+
if (ts.isBinaryExpression(parent))
|
|
37
|
+
return parent.operatorToken.kind === ts.SyntaxKind.EqualsToken && parent.left === current;
|
|
38
|
+
return (ts.isForInStatement(parent) || ts.isForOfStatement(parent)) && parent.initializer === current;
|
|
39
|
+
}
|
|
40
|
+
// `?.` cannot start an assignment, `delete` or `++` target, or a tagged template tag.
|
|
41
|
+
function endsInWriteTarget(access) {
|
|
42
|
+
let top = access;
|
|
43
|
+
while ((isAccess(top.parent) && top.parent.expression === top) ||
|
|
44
|
+
(ts.isCallExpression(top.parent) && top.parent.expression === top) ||
|
|
45
|
+
ts.isNonNullExpression(top.parent) ||
|
|
46
|
+
ts.isParenthesizedExpression(top.parent))
|
|
47
|
+
top = top.parent;
|
|
48
|
+
if (isDestructuringTarget(top))
|
|
49
|
+
return true;
|
|
50
|
+
const parent = top.parent;
|
|
51
|
+
if (ts.isTaggedTemplateExpression(parent))
|
|
52
|
+
return parent.tag === top;
|
|
53
|
+
if (ts.isDeleteExpression(parent) || ts.isForInStatement(parent) || ts.isForOfStatement(parent))
|
|
54
|
+
return true;
|
|
55
|
+
if (ts.isPrefixUnaryExpression(parent) || ts.isPostfixUnaryExpression(parent))
|
|
56
|
+
return parent.operator === ts.SyntaxKind.PlusPlusToken || parent.operator === ts.SyntaxKind.MinusMinusToken;
|
|
57
|
+
return ts.isBinaryExpression(parent) && parent.left === top && isAssignmentOperator(parent.operatorToken.kind);
|
|
58
|
+
}
|
|
59
|
+
function optionalAccessFix({ node, text }) {
|
|
60
|
+
if (!node || text === undefined)
|
|
61
|
+
return;
|
|
62
|
+
const access = reportedAccess(node);
|
|
63
|
+
if (!access || access.questionDotToken || endsInWriteTarget(access))
|
|
64
|
+
return;
|
|
65
|
+
const isProperty = ts.isPropertyAccessExpression(access);
|
|
66
|
+
const operatorEnd = isProperty ? access.name.getStart() : access.argumentExpression.getStart();
|
|
67
|
+
const gap = text.slice(access.expression.end, operatorEnd);
|
|
68
|
+
const operator = isProperty ? '.' : '[';
|
|
69
|
+
const offset = gap.lastIndexOf(operator);
|
|
70
|
+
if (offset < 0)
|
|
71
|
+
return;
|
|
72
|
+
const start = access.expression.end + offset;
|
|
73
|
+
return {
|
|
74
|
+
edits: [{ start, end: start + 1, text: isProperty ? '?.' : '?.[' }],
|
|
75
|
+
note,
|
|
76
|
+
requiresReview: true,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const builders = { 'unguarded-boundary-access': optionalAccessFix };
|
|
80
|
+
export default builders;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Moves the release of a file handle, query runner or browser into a finally block. The statements
|
|
2
|
+
// after the acquisition keep their indentation so the change stays a small, reviewable hunk; the
|
|
3
|
+
// project's formatter re-indents them.
|
|
4
|
+
import { ts, ancestor, indentationAt } from '../../performance/site-fixes/helpers.js';
|
|
5
|
+
import { walkNodes } from '../walk.js';
|
|
6
|
+
const reviewNote = 'The statements after the acquisition now sit in a try block, so the release also runs when one of them throws. Re-indent them with your formatter and check that nothing declared inside is used after the block.';
|
|
7
|
+
function releaseSpecFor(ruleId, declaration) {
|
|
8
|
+
if (ruleId === 'query-runner-not-released')
|
|
9
|
+
return { methods: ['release'], call: 'release' };
|
|
10
|
+
if (ruleId === 'file-handle-not-closed')
|
|
11
|
+
return { methods: ['close'], call: 'close' };
|
|
12
|
+
const initializer = declaration.initializer && ts.skipOuterExpressions(declaration.initializer);
|
|
13
|
+
const call = initializer && ts.isAwaitExpression(initializer) ? ts.skipOuterExpressions(initializer.expression) : undefined;
|
|
14
|
+
const callee = call && ts.isCallExpression(call) ? ts.skipOuterExpressions(call.expression) : undefined;
|
|
15
|
+
const connects = callee !== undefined && ts.isPropertyAccessExpression(callee) && callee.name.text === 'connect';
|
|
16
|
+
const connectsByName = callee !== undefined && ts.isIdentifier(callee) && callee.text === 'connect';
|
|
17
|
+
return connects || connectsByName
|
|
18
|
+
? { methods: ['disconnect', 'close'], call: 'disconnect' }
|
|
19
|
+
: { methods: ['close'], call: 'close' };
|
|
20
|
+
}
|
|
21
|
+
function isAsyncContext(statement) {
|
|
22
|
+
const owner = ancestor(statement.parent, ts.isFunctionLike);
|
|
23
|
+
if (!owner)
|
|
24
|
+
return true;
|
|
25
|
+
return Boolean(ts.getCombinedModifierFlags(owner) & ts.ModifierFlags.Async);
|
|
26
|
+
}
|
|
27
|
+
function callsOnVariable(statements, name, methods) {
|
|
28
|
+
const calls = [];
|
|
29
|
+
const collect = (node) => {
|
|
30
|
+
if (ts.isCallExpression(node) &&
|
|
31
|
+
ts.isPropertyAccessExpression(node.expression) &&
|
|
32
|
+
ts.isIdentifier(node.expression.expression) &&
|
|
33
|
+
node.expression.expression.text === name &&
|
|
34
|
+
methods.includes(node.expression.name.text))
|
|
35
|
+
calls.push(node);
|
|
36
|
+
};
|
|
37
|
+
for (const statement of statements)
|
|
38
|
+
walkNodes(statement, collect);
|
|
39
|
+
return calls;
|
|
40
|
+
}
|
|
41
|
+
function declaresVar(statement) {
|
|
42
|
+
return (ts.isVariableStatement(statement) &&
|
|
43
|
+
!(statement.declarationList.flags & (ts.NodeFlags.Let | ts.NodeFlags.Const | ts.NodeFlags.Using)));
|
|
44
|
+
}
|
|
45
|
+
// `return handle.readFile();` hands back a promise that is still running when the finally block
|
|
46
|
+
// closes the handle, so the release would come too early.
|
|
47
|
+
function returnsUnawaitedCall(statement) {
|
|
48
|
+
let found = false;
|
|
49
|
+
const visit = (node) => {
|
|
50
|
+
if (found || ts.isFunctionLike(node))
|
|
51
|
+
return;
|
|
52
|
+
if (ts.isReturnStatement(node) && node.expression && containsUnawaitedCall(node.expression))
|
|
53
|
+
found = true;
|
|
54
|
+
ts.forEachChild(node, visit);
|
|
55
|
+
};
|
|
56
|
+
visit(statement);
|
|
57
|
+
return found;
|
|
58
|
+
}
|
|
59
|
+
function containsUnawaitedCall(expression) {
|
|
60
|
+
if (ts.isAwaitExpression(expression) || ts.isFunctionLike(expression))
|
|
61
|
+
return false;
|
|
62
|
+
if (ts.isCallExpression(expression) || ts.isNewExpression(expression) || ts.isTaggedTemplateExpression(expression))
|
|
63
|
+
return true;
|
|
64
|
+
return ts.forEachChild(expression, (child) => containsUnawaitedCall(child) || undefined) ?? false;
|
|
65
|
+
}
|
|
66
|
+
// The whole statement `await x.close();` when `call` is all of it.
|
|
67
|
+
function releaseStatementOf(call) {
|
|
68
|
+
const parent = call.parent;
|
|
69
|
+
const statement = ts.isAwaitExpression(parent) ? parent.parent : parent;
|
|
70
|
+
return ts.isExpressionStatement(statement) ? statement : undefined;
|
|
71
|
+
}
|
|
72
|
+
function wrapInFinally({ finding, node, sourceFile, text }) {
|
|
73
|
+
if (!node || !sourceFile || text === undefined)
|
|
74
|
+
return;
|
|
75
|
+
const declaration = ancestor(node, ts.isVariableDeclaration);
|
|
76
|
+
if (!declaration || !ts.isIdentifier(declaration.name))
|
|
77
|
+
return;
|
|
78
|
+
const statement = declaration.parent.parent;
|
|
79
|
+
if (!ts.isVariableStatement(statement) || statement.modifiers || statement.declarationList.declarations.length !== 1)
|
|
80
|
+
return;
|
|
81
|
+
// Module level is left alone: wrapping would pull exports, imports and declarations into the try
|
|
82
|
+
// block and relies on top-level await, which only ES modules have.
|
|
83
|
+
const block = statement.parent;
|
|
84
|
+
if (!ts.isBlock(block))
|
|
85
|
+
return;
|
|
86
|
+
const following = block.statements.slice(block.statements.indexOf(statement) + 1);
|
|
87
|
+
const last = following.at(-1);
|
|
88
|
+
const spec = releaseSpecFor(finding.ruleId, declaration);
|
|
89
|
+
if (!last || !spec || following.some(declaresVar) || !isAsyncContext(statement))
|
|
90
|
+
return;
|
|
91
|
+
if (following.some(returnsUnawaitedCall))
|
|
92
|
+
return;
|
|
93
|
+
return buildEdits({ sourceFile, text, name: declaration.name.text, statement, following, last, spec });
|
|
94
|
+
}
|
|
95
|
+
function buildEdits({ sourceFile, text, name, statement, following, last, spec }) {
|
|
96
|
+
const indentation = indentationAt(text, statement.getStart(sourceFile));
|
|
97
|
+
const existing = callsOnVariable(following, name, spec.methods);
|
|
98
|
+
const releaseText = `await ${name}.${spec.call}();`;
|
|
99
|
+
const open = { start: statement.end, end: statement.end, text: `\n${indentation}try {` };
|
|
100
|
+
if (existing.length === 0) {
|
|
101
|
+
const close = {
|
|
102
|
+
start: last.end,
|
|
103
|
+
end: last.end,
|
|
104
|
+
text: `\n${indentation}} finally {\n${indentation} ${releaseText}\n${indentation}}`,
|
|
105
|
+
};
|
|
106
|
+
return { edits: [open, close], note: reviewNote, requiresReview: true };
|
|
107
|
+
}
|
|
108
|
+
// Only a release that is a whole statement ending the block can be moved without reordering code.
|
|
109
|
+
const [release] = existing;
|
|
110
|
+
const releaseStatement = existing.length === 1 ? releaseStatementOf(release) : undefined;
|
|
111
|
+
if (!releaseStatement || releaseStatement !== last || following.length < 2)
|
|
112
|
+
return;
|
|
113
|
+
const releaseSource = releaseStatement.getText(sourceFile);
|
|
114
|
+
const close = {
|
|
115
|
+
start: releaseStatement.getStart(sourceFile),
|
|
116
|
+
end: releaseStatement.end,
|
|
117
|
+
text: `} finally {\n${indentation} ${releaseSource}\n${indentation}}`,
|
|
118
|
+
};
|
|
119
|
+
return { edits: [open, close], note: reviewNote, requiresReview: true };
|
|
120
|
+
}
|
|
121
|
+
export default {
|
|
122
|
+
'file-handle-not-closed': wrapInFinally,
|
|
123
|
+
'query-runner-not-released': wrapInFinally,
|
|
124
|
+
'browser-not-closed': wrapInFinally,
|
|
125
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { ts, ancestor, hasCommentBetween, lineStart, replaceNode } from '../../performance/site-fixes/helpers.js';
|
|
2
|
+
import { closestTypeofName, containerStatements, nanComparedOperand, unreachableRun } from '../suspicious-logic.js';
|
|
3
|
+
import { isEqualityOperator, isNegatedEquality } from '../source-helpers.js';
|
|
4
|
+
// The finding sits at the start of its expression, which nested operands share, so take the
|
|
5
|
+
// innermost matching binary expression that starts there.
|
|
6
|
+
function binaryStartingAt(node, matchesOperator) {
|
|
7
|
+
const start = node.getStart();
|
|
8
|
+
return ancestor(node, (candidate) => ts.isBinaryExpression(candidate) &&
|
|
9
|
+
candidate.getStart() === start &&
|
|
10
|
+
matchesOperator(candidate.operatorToken.kind));
|
|
11
|
+
}
|
|
12
|
+
function replaceOperator(binary, operator) {
|
|
13
|
+
return replaceNode(binary.operatorToken, operator);
|
|
14
|
+
}
|
|
15
|
+
function assignmentFix({ node }) {
|
|
16
|
+
if (!node)
|
|
17
|
+
return;
|
|
18
|
+
const assignment = binaryStartingAt(node, (kind) => kind === ts.SyntaxKind.EqualsToken);
|
|
19
|
+
if (!assignment)
|
|
20
|
+
return;
|
|
21
|
+
return {
|
|
22
|
+
edits: [replaceOperator(assignment, '===')],
|
|
23
|
+
note: 'The condition no longer assigns, so later code that relied on the new value of the variable needs the assignment as its own statement.',
|
|
24
|
+
requiresReview: true,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function nanFix({ node, text }) {
|
|
28
|
+
if (!node || text === undefined)
|
|
29
|
+
return;
|
|
30
|
+
const comparison = binaryStartingAt(node, isEqualityOperator);
|
|
31
|
+
const operand = comparison && nanComparedOperand(comparison);
|
|
32
|
+
// The whole comparison is rebuilt from its operand, which would drop a comment inside it.
|
|
33
|
+
if (!comparison || !operand || hasCommentBetween(text, comparison.getStart(), comparison.end))
|
|
34
|
+
return;
|
|
35
|
+
const negated = isNegatedEquality(comparison.operatorToken.kind);
|
|
36
|
+
return {
|
|
37
|
+
edits: [replaceNode(comparison, `${negated ? '!' : ''}Number.isNaN(${operand.getText()})`)],
|
|
38
|
+
note: 'Number.isNaN is true only for the NaN value itself, which is what the comparison was meant to test.',
|
|
39
|
+
// A comparison that was always false (or true) now varies, so a branch that never ran can start running.
|
|
40
|
+
requiresReview: true,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function typeofFix({ node }) {
|
|
44
|
+
if (!node)
|
|
45
|
+
return;
|
|
46
|
+
const literal = ancestor(node, ts.isStringLiteral);
|
|
47
|
+
const name = literal && closestTypeofName(literal.text);
|
|
48
|
+
if (!literal || !name)
|
|
49
|
+
return;
|
|
50
|
+
const quote = literal.getText()[0];
|
|
51
|
+
return {
|
|
52
|
+
edits: [replaceNode(literal, `${quote}${name}${quote}`)],
|
|
53
|
+
note: `'${literal.text}' looks like a misspelling of '${name}'.`,
|
|
54
|
+
// The comparison could never match before; once it can, the branch it guards starts running.
|
|
55
|
+
requiresReview: true,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
// Removes the statement's whole line when nothing else shares it, so no blank indented line is left.
|
|
59
|
+
function deleteStatement(text, statement) {
|
|
60
|
+
const start = statement.getStart();
|
|
61
|
+
const lineBegin = lineStart(text, start);
|
|
62
|
+
const newline = text.indexOf('\n', statement.end);
|
|
63
|
+
const lineEnd = newline === -1 ? text.length : newline;
|
|
64
|
+
const aloneOnLine = !text.slice(lineBegin, start).trim() && !text.slice(statement.end, lineEnd).trim();
|
|
65
|
+
if (!aloneOnLine)
|
|
66
|
+
return { start, end: statement.end, text: '' };
|
|
67
|
+
return { start: lineBegin, end: Math.min(lineEnd + 1, text.length), text: '' };
|
|
68
|
+
}
|
|
69
|
+
// A `var` is hoisted to the function, so deleting its declaration turns an earlier read from undefined into a
|
|
70
|
+
// ReferenceError.
|
|
71
|
+
function declaresVar(node) {
|
|
72
|
+
if (ts.isFunctionLike(node))
|
|
73
|
+
return false;
|
|
74
|
+
if (ts.isVariableDeclarationList(node) && (node.flags & ts.NodeFlags.BlockScoped) === 0)
|
|
75
|
+
return true;
|
|
76
|
+
return ts.forEachChild(node, (child) => declaresVar(child) || undefined) ?? false;
|
|
77
|
+
}
|
|
78
|
+
function unreachableFix({ node, text }) {
|
|
79
|
+
if (!node || text === undefined)
|
|
80
|
+
return;
|
|
81
|
+
const statement = ancestor(node, (candidate) => {
|
|
82
|
+
const siblings = candidate.parent && containerStatements(candidate.parent);
|
|
83
|
+
return siblings !== undefined && siblings.some((sibling) => sibling === candidate);
|
|
84
|
+
});
|
|
85
|
+
const siblings = statement?.parent && containerStatements(statement.parent);
|
|
86
|
+
const run = siblings && unreachableRun(siblings);
|
|
87
|
+
if (!run || run.unreachable[0] !== statement || run.unreachable.some(declaresVar))
|
|
88
|
+
return;
|
|
89
|
+
return {
|
|
90
|
+
edits: run.unreachable.map((unreachable) => deleteStatement(text, unreachable)),
|
|
91
|
+
note: 'Deleting the code loses it for good. If the exit is a leftover from debugging, remove the exit instead.',
|
|
92
|
+
requiresReview: true,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function loopBoundFix({ node }) {
|
|
96
|
+
if (!node)
|
|
97
|
+
return;
|
|
98
|
+
const condition = binaryStartingAt(node, (kind) => kind === ts.SyntaxKind.LessThanEqualsToken);
|
|
99
|
+
if (!condition)
|
|
100
|
+
return;
|
|
101
|
+
return {
|
|
102
|
+
edits: [replaceOperator(condition, '<')],
|
|
103
|
+
note: 'Valid indexes run from 0 to length - 1, so the loop stops before length.',
|
|
104
|
+
// Code after the loop, or a body that relies on the extra pass, sees one iteration fewer.
|
|
105
|
+
requiresReview: true,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const builders = {
|
|
109
|
+
'assignment-in-condition': assignmentFix,
|
|
110
|
+
'nan-comparison': nanFix,
|
|
111
|
+
'invalid-typeof-comparison': typeofFix,
|
|
112
|
+
'unreachable-code': unreachableFix,
|
|
113
|
+
'loop-index-past-length': loopBoundFix,
|
|
114
|
+
};
|
|
115
|
+
export default builders;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Small syntax helpers shared by the reliability rules that read source files.
|
|
2
|
+
import { ts } from '../performance/compiler.js';
|
|
3
|
+
import { testSourcePattern } from '../maintainability/snapshot-context.js';
|
|
4
|
+
import { generatedSource } from '../maintainability/duplicates.js';
|
|
5
|
+
// Static assets and bundled third-party code are copied as they are, not maintained here.
|
|
6
|
+
const vendoredFolder = /(?:^|\/)(?:vendors?|third[-_]party|assets)\//i;
|
|
7
|
+
// Test, vendored and generated sources are not the project's own code to fix.
|
|
8
|
+
function isIgnoredSource(sourceFile, file) {
|
|
9
|
+
return (testSourcePattern.test(file) || vendoredFolder.test(file.replaceAll('\\', '/')) || generatedSource(sourceFile, file));
|
|
10
|
+
}
|
|
11
|
+
function withoutParentheses(expression) {
|
|
12
|
+
let current = expression;
|
|
13
|
+
while (ts.isParenthesizedExpression(current))
|
|
14
|
+
current = current.expression;
|
|
15
|
+
return current;
|
|
16
|
+
}
|
|
17
|
+
function isAccess(node) {
|
|
18
|
+
return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node);
|
|
19
|
+
}
|
|
20
|
+
function isAssignmentOperator(kind) {
|
|
21
|
+
return kind >= ts.SyntaxKind.FirstAssignment && kind <= ts.SyntaxKind.LastAssignment;
|
|
22
|
+
}
|
|
23
|
+
function isEqualityOperator(kind) {
|
|
24
|
+
return (kind === ts.SyntaxKind.EqualsEqualsEqualsToken ||
|
|
25
|
+
kind === ts.SyntaxKind.EqualsEqualsToken ||
|
|
26
|
+
kind === ts.SyntaxKind.ExclamationEqualsEqualsToken ||
|
|
27
|
+
kind === ts.SyntaxKind.ExclamationEqualsToken);
|
|
28
|
+
}
|
|
29
|
+
function isNegatedEquality(kind) {
|
|
30
|
+
return kind === ts.SyntaxKind.ExclamationEqualsEqualsToken || kind === ts.SyntaxKind.ExclamationEqualsToken;
|
|
31
|
+
}
|
|
32
|
+
export { isAccess, isAssignmentOperator, isEqualityOperator, isIgnoredSource, isNegatedEquality, withoutParentheses };
|