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,603 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import ts from 'typescript';
|
|
4
|
+
import { localDockerBuild, dockerNodeEntry } from './docker-entry-points.js';
|
|
5
|
+
import { noteUnreadable } from '../shared/coverage-notes.js';
|
|
6
|
+
import { configFile, jsonConfigFile, configFilePaths, jsonConfigFilePaths } from './config-entry-points.js';
|
|
7
|
+
import { mochaConfigYaml, mochaScriptPaths, mochaYamlPaths } from './mocha-entry-points.js';
|
|
8
|
+
import { htmlScriptEntries, maxHtmlEntryBytes } from './html-entry-points.js';
|
|
9
|
+
import { operatorReferences } from './operator-references.js';
|
|
10
|
+
import { runtimeDirectories, isInside } from './runtime-directories.js';
|
|
11
|
+
import { testSourcePattern } from './snapshot-context.js';
|
|
12
|
+
import { walkNodes } from './walk.js';
|
|
13
|
+
import { workflowNodeEntries } from './workflow-entry-points.js';
|
|
14
|
+
import { maxConsumerBytes, placeholderMaxBytes } from './source-facts.js';
|
|
15
|
+
import { collectModuleUsage } from './module-usage.js';
|
|
16
|
+
function isRecord(value) {
|
|
17
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
18
|
+
}
|
|
19
|
+
const sourceExtensions = ['.ts', '.tsx', '.mts', '.cts', '.js', '.jsx', '.mjs', '.cjs'];
|
|
20
|
+
const builtExtensions = {
|
|
21
|
+
'.js': ['.ts', '.tsx'],
|
|
22
|
+
'.mjs': ['.mts'],
|
|
23
|
+
'.cjs': ['.cts'],
|
|
24
|
+
'.jsx': ['.tsx'],
|
|
25
|
+
};
|
|
26
|
+
const outputFolders = new Set(['dist', 'build', 'lib', 'out']);
|
|
27
|
+
const commandSeparators = /[\s'"=]+/;
|
|
28
|
+
const routeFrameworks = /^(?:next|nuxt|@remix-run\/.+|react-router|@react-router\/.+|@sveltejs\/kit|astro|gatsby)$/;
|
|
29
|
+
// Files that tools, frameworks or people run directly, or that are discovered by folder or file
|
|
30
|
+
// name instead of an import.
|
|
31
|
+
const conventionalFolder = /(?:^|\/)(?:__tests__|__mocks__|tests?|e2e|cypress|playwright|\.storybook|scripts?|bin|[\w-]*migrations?[\w-]*|seeds?|seeders?|prisma|pages|routes|examples?|docs|benchmarks?|fixtures|public|static)\//i;
|
|
32
|
+
const conventionalName = /(?:[.-](?:config|entity|migration|subscriber|seed|seeder|stories|story|global-?setup)\.[cm]?[jt]sx?$|(?:^|\/)\.?[\w-]*rc\.[cm]?[jt]s$|(?:^|\/)\d{10,}[\w-]*\.[jt]s$|(?:^|\/)(?:gulpfile|gruntfile|main|middleware|instrumentation|global-?setup)\.[cm]?[jt]sx?$|(?:^|\/)(?:jest|vitest)\.(?:setup|global-?setup)|(?:^|\/)app\/(?:entry\.client|entry\.server|root|routes)\.[cm]?[jt]sx?$)/i;
|
|
33
|
+
const packageRootEntry = /^(?:src\/)?(?:index|server|app|worker|cli|handler)\.[cm]?[jt]sx?$/;
|
|
34
|
+
const githubWorkflow = /^\.github\/workflows\/[^/]+\.ya?ml$/;
|
|
35
|
+
function readConfig(root, file) {
|
|
36
|
+
const absolute = path.join(root, file);
|
|
37
|
+
const text = ts.sys.readFile(absolute);
|
|
38
|
+
if (text === undefined)
|
|
39
|
+
return {};
|
|
40
|
+
return ts.parseConfigFileTextToJson(absolute, text).config ?? {};
|
|
41
|
+
}
|
|
42
|
+
function stringValues(value) {
|
|
43
|
+
if (typeof value === 'string')
|
|
44
|
+
return [value];
|
|
45
|
+
if (Array.isArray(value))
|
|
46
|
+
return value.flatMap(stringValues);
|
|
47
|
+
if (value && typeof value === 'object')
|
|
48
|
+
return Object.values(value).flatMap(stringValues);
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
// Words of shell commands that look like a file or a path, such as `node dist/main.js` or
|
|
52
|
+
// `--entryFile queue/worker`.
|
|
53
|
+
function commandPaths(commands) {
|
|
54
|
+
return commands
|
|
55
|
+
.flatMap((command) => command.split(commandSeparators))
|
|
56
|
+
.filter((word) => /\.[cm]?[jt]sx?$/.test(word) || word.includes('/'));
|
|
57
|
+
}
|
|
58
|
+
function packageEntryPaths(manifest) {
|
|
59
|
+
const scriptTokens = commandPaths(stringValues(manifest.scripts));
|
|
60
|
+
return [
|
|
61
|
+
...stringValues([manifest.main, manifest.module, manifest.browser, manifest.bin, manifest.exports]),
|
|
62
|
+
...scriptTokens,
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
function nestEntryPaths(config) {
|
|
66
|
+
const projects = Object.values(config.projects ?? {});
|
|
67
|
+
return [config, ...projects].map((project) => `${project.sourceRoot ?? (project === config ? 'src' : project.root)}/${project.entryFile ?? 'main'}`);
|
|
68
|
+
}
|
|
69
|
+
// Node substitutes the same captured subpath for every star on the right side of an exports map.
|
|
70
|
+
function exportTargetMatcher(pattern) {
|
|
71
|
+
const parts = pattern.split('*');
|
|
72
|
+
const stars = parts.length - 1;
|
|
73
|
+
const literalLength = pattern.length - stars;
|
|
74
|
+
return (stem) => {
|
|
75
|
+
const lastPart = parts[parts.length - 1];
|
|
76
|
+
const width = (stem.length - literalLength) / stars;
|
|
77
|
+
if (width < 0 || !Number.isInteger(width) || !stem.startsWith(parts[0]) || !stem.endsWith(lastPart))
|
|
78
|
+
return false;
|
|
79
|
+
if (stars === 1)
|
|
80
|
+
return true;
|
|
81
|
+
const capture = stem.slice(parts[0].length, parts[0].length + width);
|
|
82
|
+
return parts.join(capture) === stem;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function addWildcardEntry(directory, entry, known, explicit) {
|
|
86
|
+
const relative = path.posix.normalize(entry.replaceAll('\\', '/'));
|
|
87
|
+
const extension = sourceExtensions.find((candidate) => relative.endsWith(candidate));
|
|
88
|
+
const pattern = extension ? relative.slice(0, -extension.length) : relative;
|
|
89
|
+
const [first, ...rest] = pattern.split('/');
|
|
90
|
+
const candidates = [pattern, `src/${pattern}`];
|
|
91
|
+
if (outputFolders.has(first))
|
|
92
|
+
candidates.push(['src', ...rest].join('/'));
|
|
93
|
+
const matches = candidates.map((candidate) => exportTargetMatcher(path.posix.join(directory, candidate)));
|
|
94
|
+
for (const file of known) {
|
|
95
|
+
const stem = file.slice(0, -path.posix.extname(file).length);
|
|
96
|
+
if (matches.some((match) => match(stem)))
|
|
97
|
+
explicit.add(file);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function parseScript(absolute) {
|
|
101
|
+
const text = ts.sys.readFile(absolute);
|
|
102
|
+
return text === undefined ? undefined : ts.createSourceFile(absolute, text, ts.ScriptTarget.Latest, true);
|
|
103
|
+
}
|
|
104
|
+
function literalStrings(expression) {
|
|
105
|
+
if (ts.isStringLiteralLike(expression))
|
|
106
|
+
return [expression.text];
|
|
107
|
+
if (!ts.isArrayLiteralExpression(expression))
|
|
108
|
+
return [];
|
|
109
|
+
const strings = [];
|
|
110
|
+
for (const element of expression.elements) {
|
|
111
|
+
if (!ts.isStringLiteralLike(element))
|
|
112
|
+
return [];
|
|
113
|
+
strings.push(element.text);
|
|
114
|
+
}
|
|
115
|
+
return strings;
|
|
116
|
+
}
|
|
117
|
+
// `schema: './db/*.table.ts'` (a string, array or glob) in a drizzle config names files drizzle-kit
|
|
118
|
+
// loads.
|
|
119
|
+
function drizzleSchemaPaths(sourceFile) {
|
|
120
|
+
const paths = [];
|
|
121
|
+
walkNodes(sourceFile, (node) => {
|
|
122
|
+
if (!ts.isPropertyAssignment(node) || !ts.isIdentifier(node.name) || node.name.text !== 'schema')
|
|
123
|
+
return;
|
|
124
|
+
paths.push(...literalStrings(ts.skipOuterExpressions(node.initializer)));
|
|
125
|
+
});
|
|
126
|
+
return paths;
|
|
127
|
+
}
|
|
128
|
+
const workingDirectoryCalls = /^(?:process\.cwd\(\)|__dirname|import\.meta\.dirname)$/;
|
|
129
|
+
// `.sequelizerc` names the config, models, seeders and migrations with
|
|
130
|
+
// path.resolve('src/db/config.cjs'), relative to the folder sequelize-cli runs in.
|
|
131
|
+
function sequelizePaths(sourceFile) {
|
|
132
|
+
const paths = [];
|
|
133
|
+
walkNodes(sourceFile, (node) => {
|
|
134
|
+
if (!ts.isCallExpression(node) || !ts.isPropertyAccessExpression(node.expression))
|
|
135
|
+
return;
|
|
136
|
+
if (!['resolve', 'join'].includes(node.expression.name.text))
|
|
137
|
+
return;
|
|
138
|
+
const parts = node.arguments.filter((argument) => !workingDirectoryCalls.test(argument.getText(sourceFile)));
|
|
139
|
+
if (parts.length && parts.every(ts.isStringLiteralLike))
|
|
140
|
+
paths.push(path.posix.join(...parts.map((part) => part.text)));
|
|
141
|
+
});
|
|
142
|
+
return paths;
|
|
143
|
+
}
|
|
144
|
+
function globPattern(rawGlob) {
|
|
145
|
+
const glob = rawGlob.replaceAll(/(?:\*\*\/)+/g, '**/').replaceAll(/\*{3,}/g, '**');
|
|
146
|
+
let pattern = '';
|
|
147
|
+
let insideBraces = false;
|
|
148
|
+
for (let index = 0; index < glob.length; index++) {
|
|
149
|
+
const character = glob[index];
|
|
150
|
+
if (glob.startsWith('**/', index)) {
|
|
151
|
+
pattern += '(?:.*/)?';
|
|
152
|
+
index += 2;
|
|
153
|
+
}
|
|
154
|
+
else if (glob.startsWith('**', index)) {
|
|
155
|
+
pattern += '.*';
|
|
156
|
+
index += 1;
|
|
157
|
+
}
|
|
158
|
+
else if (character === '*')
|
|
159
|
+
pattern += '[^/]*';
|
|
160
|
+
else if (character === '?')
|
|
161
|
+
pattern += '[^/]';
|
|
162
|
+
else if (character === '{' && !insideBraces && glob.indexOf('}', index + 1) !== -1) {
|
|
163
|
+
insideBraces = true;
|
|
164
|
+
pattern += '(?:';
|
|
165
|
+
}
|
|
166
|
+
else if (character === '}' && insideBraces) {
|
|
167
|
+
insideBraces = false;
|
|
168
|
+
pattern += ')';
|
|
169
|
+
}
|
|
170
|
+
else if (character === ',' && insideBraces)
|
|
171
|
+
pattern += '|';
|
|
172
|
+
else
|
|
173
|
+
pattern += character.replaceAll(/[.+^$()|[\]\\]/g, '\\$&');
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
return new RegExp('^' + pattern + '$');
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
return /$^/;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Folders from the scan root up to the first one holding package.json or .git, where tool configs
|
|
183
|
+
// usually live.
|
|
184
|
+
function configFolders(root) {
|
|
185
|
+
const folders = [];
|
|
186
|
+
for (let folder = path.resolve(root);; folder = path.dirname(folder)) {
|
|
187
|
+
folders.push(folder);
|
|
188
|
+
const boundary = fs.existsSync(path.join(folder, 'package.json')) || fs.existsSync(path.join(folder, '.git'));
|
|
189
|
+
if (boundary || path.dirname(folder) === folder)
|
|
190
|
+
return folders;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const sourceFilePattern = /\.[cm]?[jt]sx?$/;
|
|
194
|
+
const skippedFolders = new Set(['node_modules', 'dist', 'build', 'out', 'coverage']);
|
|
195
|
+
function readFolder(folder) {
|
|
196
|
+
try {
|
|
197
|
+
return fs.readdirSync(folder, { withFileTypes: true });
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
// A missing folder is expected; one that exists but cannot be listed hides files that may use
|
|
201
|
+
// an export.
|
|
202
|
+
if (!(error instanceof Error))
|
|
203
|
+
throw error;
|
|
204
|
+
noteUnreadable({ error, location: folder, consequence: 'skipped it when looking for entry points' });
|
|
205
|
+
return [];
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function sourceFilesBelow(folder) {
|
|
209
|
+
const files = [];
|
|
210
|
+
const pending = [folder];
|
|
211
|
+
for (let current = pending.pop(); current !== undefined; current = pending.pop()) {
|
|
212
|
+
for (const entry of readFolder(current)) {
|
|
213
|
+
if (entry.name.startsWith('.'))
|
|
214
|
+
continue;
|
|
215
|
+
const absolute = path.join(current, entry.name);
|
|
216
|
+
if (entry.isDirectory() && !skippedFolders.has(entry.name))
|
|
217
|
+
pending.push(absolute);
|
|
218
|
+
else if (entry.isFile() && sourceFilePattern.test(entry.name) && !/\.d\.[cm]?ts$/.test(entry.name))
|
|
219
|
+
files.push(absolute);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return files;
|
|
223
|
+
}
|
|
224
|
+
function workspaceGlobs(folder) {
|
|
225
|
+
const { workspaces } = readConfig(folder, 'package.json');
|
|
226
|
+
const declared = Array.isArray(workspaces) ? workspaces : isRecord(workspaces) ? workspaces.packages : undefined;
|
|
227
|
+
if (Array.isArray(declared))
|
|
228
|
+
return declared.filter((glob) => typeof glob === 'string');
|
|
229
|
+
const pnpm = ts.sys.readFile(path.join(folder, 'pnpm-workspace.yaml'));
|
|
230
|
+
// Only the indented lines under `packages:` list members; other keys hold lists too.
|
|
231
|
+
const packagesBlock = pnpm?.match(/^packages:[^\S\n]*\r?\n((?:[ \t]+.*(?:\r?\n|$)|[ \t]*\r?\n)*)/m);
|
|
232
|
+
if (!packagesBlock)
|
|
233
|
+
return;
|
|
234
|
+
return [...packagesBlock[1].matchAll(/^\s*-\s*['"]?([^'"#\s]+)['"]?/gm)].map((match) => match[1]);
|
|
235
|
+
}
|
|
236
|
+
// Member globs are shallow (apps/*, packages/**), so a bounded walk of folders is enough.
|
|
237
|
+
function matchingMemberFolders(folder, included) {
|
|
238
|
+
const members = [];
|
|
239
|
+
const pending = [''];
|
|
240
|
+
for (let relative = pending.pop(); relative !== undefined; relative = pending.pop()) {
|
|
241
|
+
if (relative.split('/').length > 3)
|
|
242
|
+
continue;
|
|
243
|
+
for (const entry of readFolder(path.join(folder, relative))) {
|
|
244
|
+
if (!entry.isDirectory() || entry.name.startsWith('.') || skippedFolders.has(entry.name))
|
|
245
|
+
continue;
|
|
246
|
+
const child = relative ? `${relative}/${entry.name}` : entry.name;
|
|
247
|
+
if (included.some((pattern) => pattern.test(child)))
|
|
248
|
+
members.push(path.join(folder, child));
|
|
249
|
+
pending.push(child);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return members;
|
|
253
|
+
}
|
|
254
|
+
// The ancestor monorepo that lists the scanned package as a member, with its other member folders.
|
|
255
|
+
function siblingWorkspaces(packageFolder) {
|
|
256
|
+
for (let folder = path.dirname(packageFolder); path.dirname(folder) !== folder; folder = path.dirname(folder)) {
|
|
257
|
+
const globs = workspaceGlobs(folder);
|
|
258
|
+
if (!globs) {
|
|
259
|
+
if (fs.existsSync(path.join(folder, '.git')))
|
|
260
|
+
return [];
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
const included = globs.filter((glob) => !glob.startsWith('!')).map((glob) => globPattern(glob.replace(/\/$/, '')));
|
|
264
|
+
const members = matchingMemberFolders(folder, included);
|
|
265
|
+
const scanned = path.resolve(packageFolder);
|
|
266
|
+
return members.includes(scanned) ? members.filter((member) => member !== scanned) : [];
|
|
267
|
+
}
|
|
268
|
+
return [];
|
|
269
|
+
}
|
|
270
|
+
// Folders that source code reads from by a computed file name or serves statically.
|
|
271
|
+
function collectRuntimeFolders(known, root, fileFacts) {
|
|
272
|
+
const runtimeFolders = new Set();
|
|
273
|
+
for (const file of known) {
|
|
274
|
+
const facts = fileFacts?.get(file);
|
|
275
|
+
if (facts) {
|
|
276
|
+
for (const folder of facts.runtimeFolders)
|
|
277
|
+
runtimeFolders.add(folder);
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
const size = ts.sys.getFileSize?.(path.join(root, file)) ?? 0;
|
|
281
|
+
if (!size || size > maxConsumerBytes)
|
|
282
|
+
continue;
|
|
283
|
+
for (const folder of runtimeDirectories(ts.sys.readFile(path.join(root, file)) ?? ''))
|
|
284
|
+
runtimeFolders.add(folder);
|
|
285
|
+
}
|
|
286
|
+
return runtimeFolders;
|
|
287
|
+
}
|
|
288
|
+
// Deep imports such as `@acme/lib/client/download` from sibling workspace members, as subpaths of
|
|
289
|
+
// the package with the names they import. A subpath imported several times keeps every name, and
|
|
290
|
+
// `all` once any import uses the module.
|
|
291
|
+
function siblingImports(packageName, members) {
|
|
292
|
+
const prefix = packageName + '/';
|
|
293
|
+
const imports = new Map();
|
|
294
|
+
for (const member of members) {
|
|
295
|
+
for (const file of sourceFilesBelow(member))
|
|
296
|
+
recordFileSiblingImports(imports, file, prefix);
|
|
297
|
+
}
|
|
298
|
+
return imports;
|
|
299
|
+
}
|
|
300
|
+
function recordFileSiblingImports(imports, file, prefix) {
|
|
301
|
+
if ((ts.sys.getFileSize?.(file) ?? 0) > maxConsumerBytes)
|
|
302
|
+
return;
|
|
303
|
+
const text = ts.sys.readFile(file);
|
|
304
|
+
if (!text?.includes(prefix))
|
|
305
|
+
return;
|
|
306
|
+
const source = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true);
|
|
307
|
+
for (const { specifier, names } of collectModuleUsage(source, file, () => undefined).unresolved) {
|
|
308
|
+
if (specifier.startsWith(prefix))
|
|
309
|
+
recordSiblingImport(imports, specifier.slice(prefix.length), names);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function recordSiblingImport(imports, subpath, names) {
|
|
313
|
+
const known = imports.get(subpath);
|
|
314
|
+
if (known === 'all' || names === 'all')
|
|
315
|
+
imports.set(subpath, 'all');
|
|
316
|
+
else
|
|
317
|
+
imports.set(subpath, [...new Set([...(known ?? []), ...names])]);
|
|
318
|
+
}
|
|
319
|
+
// An entry that an ancestor package.json declares relative to its own folder, such as
|
|
320
|
+
// `./dist/api/*.js`, as the path it takes from the scanned folder. The scanned `src` is what builds
|
|
321
|
+
// into that output folder.
|
|
322
|
+
function entryBelowScanRoot(entry, ancestorFolder, root) {
|
|
323
|
+
const relative = path.posix.normalize(entry.replaceAll('\\', '/'));
|
|
324
|
+
const scannedPrefix = path.relative(ancestorFolder, root).replaceAll('\\', '/') + '/';
|
|
325
|
+
if (relative.startsWith(scannedPrefix))
|
|
326
|
+
return relative.slice(scannedPrefix.length);
|
|
327
|
+
const [first, ...rest] = relative.split('/');
|
|
328
|
+
if (outputFolders.has(first))
|
|
329
|
+
return rest.join('/');
|
|
330
|
+
}
|
|
331
|
+
// A private package that declares none of these is an application rather than a library.
|
|
332
|
+
const packageEntryKeys = ['main', 'module', 'browser', 'bin', 'exports', 'types', 'typings', 'typesVersions'];
|
|
333
|
+
// `inventory` is every project-relative file; `sourceFiles` the analysed ones. Configuration files
|
|
334
|
+
// are read from disk.
|
|
335
|
+
// `fileFacts` holds what the scan already learned from each analysed file, so those files are not
|
|
336
|
+
// read again.
|
|
337
|
+
function createEntryPoints(root, inventory, sourceFiles, fileFacts) {
|
|
338
|
+
const known = new Set(sourceFiles);
|
|
339
|
+
const explicit = new Set();
|
|
340
|
+
const packageDirectories = new Map();
|
|
341
|
+
const privateApplications = new Set();
|
|
342
|
+
const workspacePackages = new Map();
|
|
343
|
+
// The analysed files that a package entry such as `dist/main.js` or `queue/worker` can name.
|
|
344
|
+
function entryFiles(directory, entry) {
|
|
345
|
+
if (entry.includes('*'))
|
|
346
|
+
return [];
|
|
347
|
+
const relative = path.posix.normalize(entry.replaceAll('\\', '/'));
|
|
348
|
+
const extension = path.posix.extname(relative);
|
|
349
|
+
const stem = sourceExtensions.includes(extension) ? relative.slice(0, -extension.length) : relative;
|
|
350
|
+
const [firstSegment, ...rest] = stem.split('/');
|
|
351
|
+
// Build output such as dist/main.js comes from src/main.ts, and tools accept paths relative to
|
|
352
|
+
// src.
|
|
353
|
+
const stems = [stem, `src/${stem}`];
|
|
354
|
+
if (outputFolders.has(firstSegment))
|
|
355
|
+
stems.push(['src', ...rest].join('/'));
|
|
356
|
+
const extensions = [...(builtExtensions[extension] ?? []), ...sourceExtensions];
|
|
357
|
+
const candidates = [relative];
|
|
358
|
+
for (const base of stems) {
|
|
359
|
+
for (const candidateExtension of extensions)
|
|
360
|
+
candidates.push(base + candidateExtension, `${base}/index${candidateExtension}`);
|
|
361
|
+
}
|
|
362
|
+
return candidates.map((candidate) => path.posix.join(directory, candidate)).filter((file) => known.has(file));
|
|
363
|
+
}
|
|
364
|
+
function addEntry(directory, entry) {
|
|
365
|
+
for (const file of entryFiles(directory, entry))
|
|
366
|
+
explicit.add(file);
|
|
367
|
+
}
|
|
368
|
+
const inventoryFiles = new Set(inventory);
|
|
369
|
+
function addDockerScriptEntries(directory, scripts) {
|
|
370
|
+
for (const script of scripts) {
|
|
371
|
+
if (typeof script !== 'string')
|
|
372
|
+
continue;
|
|
373
|
+
const build = localDockerBuild(script, directory);
|
|
374
|
+
if (!build || !inventoryFiles.has(build.dockerfile))
|
|
375
|
+
continue;
|
|
376
|
+
const entry = dockerNodeEntry(ts.sys.readFile(path.join(root, build.dockerfile)), build.contextDirectory, known);
|
|
377
|
+
if (entry)
|
|
378
|
+
explicit.add(entry);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function addManifest(directory, file) {
|
|
382
|
+
const manifest = readConfig(root, file);
|
|
383
|
+
if (manifest.private === true && !packageEntryKeys.some((key) => key in manifest))
|
|
384
|
+
privateApplications.add(directory);
|
|
385
|
+
const dependencies = { ...manifest.dependencies, ...manifest.devDependencies, ...manifest.peerDependencies };
|
|
386
|
+
if (typeof manifest.name === 'string' && directory !== '.')
|
|
387
|
+
workspacePackages.set(manifest.name, directory);
|
|
388
|
+
packageDirectories.set(directory, Object.keys(dependencies).some((dependency) => routeFrameworks.test(dependency)));
|
|
389
|
+
for (const entry of packageEntryPaths(manifest))
|
|
390
|
+
addEntry(directory, entry);
|
|
391
|
+
addDockerScriptEntries(directory, Object.values(manifest.scripts ?? {}));
|
|
392
|
+
// Mocha and Jest also read their options from package.json instead of a config file.
|
|
393
|
+
for (const script of Object.values(manifest.scripts ?? {}))
|
|
394
|
+
if (typeof script === 'string')
|
|
395
|
+
for (const entry of mochaScriptPaths(script))
|
|
396
|
+
addConfigPath(directory, entry, true);
|
|
397
|
+
for (const toolKey of ['mocha', 'jest'])
|
|
398
|
+
for (const entry of jsonConfigFilePaths(isRecord(manifest[toolKey]) ? manifest[toolKey] : {}))
|
|
399
|
+
addConfigPath(directory, entry, toolKey === 'mocha');
|
|
400
|
+
for (const entry of stringValues(manifest.exports))
|
|
401
|
+
if (entry.includes('*'))
|
|
402
|
+
addWildcardEntry(directory, entry, known, explicit);
|
|
403
|
+
}
|
|
404
|
+
function addKnownEntry(file) {
|
|
405
|
+
if (known.has(file))
|
|
406
|
+
explicit.add(file);
|
|
407
|
+
}
|
|
408
|
+
function addHtmlScripts(file, directory) {
|
|
409
|
+
const absolute = path.join(root, file);
|
|
410
|
+
const size = ts.sys.getFileSize?.(absolute);
|
|
411
|
+
if (!size || size > maxHtmlEntryBytes)
|
|
412
|
+
return;
|
|
413
|
+
for (const src of htmlScriptEntries(ts.sys.readFile(absolute))) {
|
|
414
|
+
addKnownEntry(path.posix.join(directory, src));
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
// Mocha loads every file in a folder named as a spec; other tools resolve a folder to its index,
|
|
418
|
+
// so only mocha paths expand.
|
|
419
|
+
function addFolderFiles(directory, entry) {
|
|
420
|
+
const folder = path.posix.normalize(path.posix.join(directory, entry.replaceAll('\\', '/'))).replace(/\/$/, '');
|
|
421
|
+
if (folder === '.' || folder.startsWith('..'))
|
|
422
|
+
return;
|
|
423
|
+
for (const file of known)
|
|
424
|
+
if (file.startsWith(folder + '/'))
|
|
425
|
+
explicit.add(file);
|
|
426
|
+
}
|
|
427
|
+
function addConfigPath(directory, entry, loadsFolder = false) {
|
|
428
|
+
if (!/[*?{]/.test(entry)) {
|
|
429
|
+
addEntry(directory, entry);
|
|
430
|
+
if (loadsFolder && !sourceExtensions.includes(path.posix.extname(entry)))
|
|
431
|
+
addFolderFiles(directory, entry);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
const pattern = globPattern(path.posix.normalize(path.posix.join(directory, entry)));
|
|
435
|
+
for (const file of known)
|
|
436
|
+
if (pattern.test(file))
|
|
437
|
+
explicit.add(file);
|
|
438
|
+
}
|
|
439
|
+
function addConfigFiles(file, directory) {
|
|
440
|
+
const paths = jsonConfigFile.test(file)
|
|
441
|
+
? jsonConfigFilePaths(readConfig(root, file))
|
|
442
|
+
: configFilePaths(parseScript(path.join(root, file)) ?? ts.createSourceFile(file, '', ts.ScriptTarget.Latest));
|
|
443
|
+
for (const entry of paths)
|
|
444
|
+
addConfigPath(directory, entry, /\.mocharc\./.test(file));
|
|
445
|
+
}
|
|
446
|
+
function addEntries(directory, entries) {
|
|
447
|
+
for (const entry of entries)
|
|
448
|
+
addEntry(directory, entry);
|
|
449
|
+
}
|
|
450
|
+
function addSequelizeEntries(file, directory) {
|
|
451
|
+
const sourceFile = parseScript(path.join(root, file));
|
|
452
|
+
addEntries(directory, sourceFile ? sequelizePaths(sourceFile) : []);
|
|
453
|
+
}
|
|
454
|
+
// Each file kind names its entry points in its own way; the first kind that matches wins.
|
|
455
|
+
function addFileEntries(file) {
|
|
456
|
+
const directory = path.posix.dirname(file);
|
|
457
|
+
const name = path.posix.basename(file);
|
|
458
|
+
if (name === 'package.json')
|
|
459
|
+
return addManifest(directory, file);
|
|
460
|
+
if (name === 'project.json')
|
|
461
|
+
return addEntries(directory, commandPaths(stringValues(readConfig(root, file))));
|
|
462
|
+
if (name === 'nest-cli.json')
|
|
463
|
+
return addEntries(directory, nestEntryPaths(readConfig(root, file)));
|
|
464
|
+
if (/^tsconfig(?:\..+)?\.json$/.test(name))
|
|
465
|
+
return addEntries(directory, readConfig(root, file).files ?? []);
|
|
466
|
+
if (githubWorkflow.test(file)) {
|
|
467
|
+
for (const entry of workflowNodeEntries(ts.sys.readFile(path.join(root, file)) ?? ''))
|
|
468
|
+
addKnownEntry(entry);
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
if (configFile.test(file) || jsonConfigFile.test(file))
|
|
472
|
+
return addConfigFiles(file, directory);
|
|
473
|
+
if (/\.html$/i.test(name))
|
|
474
|
+
return addHtmlScripts(file, directory);
|
|
475
|
+
if (mochaConfigYaml.test(name)) {
|
|
476
|
+
for (const entry of mochaYamlPaths(ts.sys.readFile(path.join(root, file)) ?? ''))
|
|
477
|
+
addConfigPath(directory, entry, true);
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
if (name === '.sequelizerc')
|
|
481
|
+
addSequelizeEntries(file, directory);
|
|
482
|
+
}
|
|
483
|
+
for (const file of inventory)
|
|
484
|
+
addFileEntries(file);
|
|
485
|
+
// Folders that source code reads from by a computed file name or serves statically hold files
|
|
486
|
+
// nothing imports.
|
|
487
|
+
const runtimeFolders = [...collectRuntimeFolders(known, root, fileFacts)];
|
|
488
|
+
if (runtimeFolders.length) {
|
|
489
|
+
for (const file of known)
|
|
490
|
+
if (runtimeFolders.some((folder) => isInside(file, folder)))
|
|
491
|
+
explicit.add(file);
|
|
492
|
+
}
|
|
493
|
+
// Drizzle configs often sit above the scanned folder, at the package or repository root.
|
|
494
|
+
function addPathOrGlob(configFolder, entry) {
|
|
495
|
+
const relative = path.relative(root, path.resolve(configFolder, entry)).replaceAll('\\', '/');
|
|
496
|
+
if (!relative || relative.startsWith('..'))
|
|
497
|
+
return;
|
|
498
|
+
if (/[*?{]/.test(entry)) {
|
|
499
|
+
const pattern = globPattern(relative);
|
|
500
|
+
for (const file of known)
|
|
501
|
+
if (pattern.test(file))
|
|
502
|
+
explicit.add(file);
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
// A folder schema loads every file in it.
|
|
506
|
+
addEntry('.', relative);
|
|
507
|
+
for (const file of known)
|
|
508
|
+
if (file.startsWith(relative + '/'))
|
|
509
|
+
explicit.add(file);
|
|
510
|
+
}
|
|
511
|
+
function addDrizzleSchemas(folder) {
|
|
512
|
+
for (const extension of ['.ts', '.js', '.mjs', '.cjs', '.mts', '.cts']) {
|
|
513
|
+
const sourceFile = parseScript(path.join(folder, 'drizzle.config' + extension));
|
|
514
|
+
for (const entry of sourceFile ? drizzleSchemaPaths(sourceFile) : [])
|
|
515
|
+
addPathOrGlob(folder, entry);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
for (const folder of configFolders(root))
|
|
519
|
+
addDrizzleSchemas(folder);
|
|
520
|
+
// A package.json above the scanned folder lists the package's public entry points, which build
|
|
521
|
+
// from this folder.
|
|
522
|
+
function addAncestorManifest(folder) {
|
|
523
|
+
const manifest = readConfig(folder, 'package.json');
|
|
524
|
+
const entries = stringValues([manifest.main, manifest.module, manifest.browser, manifest.bin, manifest.exports]);
|
|
525
|
+
for (const entry of entries) {
|
|
526
|
+
const entryBelowRoot = entryBelowScanRoot(entry, folder, root);
|
|
527
|
+
if (entryBelowRoot === undefined)
|
|
528
|
+
continue;
|
|
529
|
+
if (entry.includes('*'))
|
|
530
|
+
addWildcardEntry('.', entryBelowRoot, known, explicit);
|
|
531
|
+
else
|
|
532
|
+
addEntry('.', entryBelowRoot);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
for (const folder of configFolders(root).slice(1)) {
|
|
536
|
+
if (fs.existsSync(path.join(folder, 'package.json')))
|
|
537
|
+
addAncestorManifest(folder);
|
|
538
|
+
}
|
|
539
|
+
// Another member of the same monorepo may deep-import this package by name, which no scanned file
|
|
540
|
+
// shows.
|
|
541
|
+
const siblingUsages = [];
|
|
542
|
+
const ownManifest = readConfig(root, 'package.json');
|
|
543
|
+
if (typeof ownManifest.name === 'string') {
|
|
544
|
+
for (const [subpath, names] of siblingImports(ownManifest.name, siblingWorkspaces(root))) {
|
|
545
|
+
for (const file of entryFiles('.', subpath))
|
|
546
|
+
siblingUsages.push({ to: file, names });
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
function nearestPackage(file) {
|
|
550
|
+
for (let directory = path.posix.dirname(file);; directory = path.posix.dirname(directory)) {
|
|
551
|
+
if (packageDirectories.has(directory))
|
|
552
|
+
return directory;
|
|
553
|
+
if (directory === '.')
|
|
554
|
+
return '.';
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
function packageRelative(file) {
|
|
558
|
+
const packageDirectory = nearestPackage(file);
|
|
559
|
+
return packageDirectory === '.' ? file : file.slice(packageDirectory.length + 1);
|
|
560
|
+
}
|
|
561
|
+
// Tests, scripts, configuration and migrations are run by tools, so what they load says nothing
|
|
562
|
+
// about the application.
|
|
563
|
+
function isToolingFile(file) {
|
|
564
|
+
// Files beside package.json are scripts run by hand, a Dockerfile or CI.
|
|
565
|
+
return (testSourcePattern.test(file) ||
|
|
566
|
+
conventionalFolder.test(file) ||
|
|
567
|
+
conventionalName.test(file) ||
|
|
568
|
+
!packageRelative(file).includes('/'));
|
|
569
|
+
}
|
|
570
|
+
// A file holding only comments, kept on purpose so that a build or tool finds the path it
|
|
571
|
+
// expects.
|
|
572
|
+
const placeholders = new Map();
|
|
573
|
+
function isPlaceholder(file) {
|
|
574
|
+
const facts = fileFacts?.get(file);
|
|
575
|
+
if (facts)
|
|
576
|
+
return facts.placeholder;
|
|
577
|
+
const cached = placeholders.get(file);
|
|
578
|
+
if (cached !== undefined)
|
|
579
|
+
return cached;
|
|
580
|
+
const size = ts.sys.getFileSize?.(path.join(root, file)) ?? Infinity;
|
|
581
|
+
const sourceFile = size <= placeholderMaxBytes ? parseScript(path.join(root, file)) : undefined;
|
|
582
|
+
const placeholder = sourceFile !== undefined && sourceFile.statements.length === 0;
|
|
583
|
+
placeholders.set(file, placeholder);
|
|
584
|
+
return placeholder;
|
|
585
|
+
}
|
|
586
|
+
function isEntryPoint(file) {
|
|
587
|
+
if (explicit.has(file) ||
|
|
588
|
+
isPlaceholder(file) ||
|
|
589
|
+
isToolingFile(file) ||
|
|
590
|
+
packageRootEntry.test(packageRelative(file)))
|
|
591
|
+
return true;
|
|
592
|
+
return /(?:^|\/)app\//.test(file) && packageDirectories.get(nearestPackage(file)) === true;
|
|
593
|
+
}
|
|
594
|
+
return {
|
|
595
|
+
isEntryPoint,
|
|
596
|
+
operatorScripts: operatorReferences(root, inventory, known),
|
|
597
|
+
siblingUsages,
|
|
598
|
+
isToolingFile,
|
|
599
|
+
workspacePackages,
|
|
600
|
+
isPrivateApplication: (file) => privateApplications.has(nearestPackage(file)),
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
export { createEntryPoints };
|