@c4a/extract-go 0.6.18 → 0.7.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/README.md +10 -1
- package/README.zh-CN.md +9 -1
- package/index.js +1314 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,10 +28,19 @@ Context candidates → review → approved knowledge
|
|
|
28
28
|
## Public APIs
|
|
29
29
|
|
|
30
30
|
```ts
|
|
31
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
GoPlugin,
|
|
33
|
+
goExtractionToEvidenceAdapterResult,
|
|
34
|
+
indexGoRepository,
|
|
35
|
+
indexGoSource,
|
|
36
|
+
} from "@c4a/extract-go";
|
|
32
37
|
```
|
|
33
38
|
|
|
34
39
|
- `GoPlugin` implements the standard `@c4a/extract` plugin protocol.
|
|
40
|
+
- `GoPlugin` reports `ast-catalog` capabilities and an explicit disposition for
|
|
41
|
+
every parsed Go file.
|
|
42
|
+
- `goExtractionToEvidenceAdapterResult()` publishes the common
|
|
43
|
+
`context.indexer.evidence-adapter-result/v1` wire result.
|
|
35
44
|
- `indexGoSource()` parses one source unit when an adapter needs detailed facts
|
|
36
45
|
before producing candidates.
|
|
37
46
|
- `indexGoRepository()` indexes a repository tree with deterministic controls
|
package/README.zh-CN.md
CHANGED
|
@@ -24,10 +24,18 @@ Context 候选 → 审核 → 正式知识
|
|
|
24
24
|
## 公开 API
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
GoPlugin,
|
|
29
|
+
goExtractionToEvidenceAdapterResult,
|
|
30
|
+
indexGoRepository,
|
|
31
|
+
indexGoSource,
|
|
32
|
+
} from "@c4a/extract-go";
|
|
28
33
|
```
|
|
29
34
|
|
|
30
35
|
- `GoPlugin` 实现标准 `@c4a/extract` 插件协议;
|
|
36
|
+
- `GoPlugin` 声明 `ast-catalog` capability,并为每个解析的 Go 文件返回显式 disposition;
|
|
37
|
+
- `goExtractionToEvidenceAdapterResult()` 发布统一的
|
|
38
|
+
`context.indexer.evidence-adapter-result/v1` 线协议结果;
|
|
31
39
|
- `indexGoSource()` 解析一个源码单元,供 Adapter 在生成候选前读取细粒度事实;
|
|
32
40
|
- `indexGoRepository()` 索引仓库树,并通过确定性参数控制 include root、测试文件、
|
|
33
41
|
生成文件和排除目录。
|
package/index.js
CHANGED
|
@@ -11375,6 +11375,397 @@ var factSchema = exports_external.union([
|
|
|
11375
11375
|
activeFactSchema,
|
|
11376
11376
|
deprecatedFactSchema
|
|
11377
11377
|
]);
|
|
11378
|
+
// ../core/src/schemas/indexerEvidenceAdapterSchema.ts
|
|
11379
|
+
import { createHash } from "node:crypto";
|
|
11380
|
+
|
|
11381
|
+
// ../core/src/indexerOutputRedaction.ts
|
|
11382
|
+
var INDEXER_OUTPUT_REDACTION_MARKER = "[REDACTED:indexer-output]";
|
|
11383
|
+
var SECRET_TOKEN = /^(?:password|passwd|pwd|secret|token|credential|credentials|cookie)$/u;
|
|
11384
|
+
var SECRET_COMPOUND = /^(?:api-key|access-key|private-key|client-secret|access-token|refresh-token)$/u;
|
|
11385
|
+
var NON_SECRET_SUFFIX = new Set([
|
|
11386
|
+
"budget",
|
|
11387
|
+
"count",
|
|
11388
|
+
"digest",
|
|
11389
|
+
"fingerprint",
|
|
11390
|
+
"hash",
|
|
11391
|
+
"index",
|
|
11392
|
+
"kind",
|
|
11393
|
+
"length",
|
|
11394
|
+
"limit",
|
|
11395
|
+
"name",
|
|
11396
|
+
"ref",
|
|
11397
|
+
"reference",
|
|
11398
|
+
"references",
|
|
11399
|
+
"refs",
|
|
11400
|
+
"status",
|
|
11401
|
+
"type"
|
|
11402
|
+
]);
|
|
11403
|
+
function keyTokens(key) {
|
|
11404
|
+
return key.replace(/([a-z0-9])([A-Z])/gu, "$1-$2").replace(/[^A-Za-z0-9]+/gu, "-").toLowerCase().split("-").filter(Boolean);
|
|
11405
|
+
}
|
|
11406
|
+
function sensitiveKey(key, value) {
|
|
11407
|
+
const tokens = keyTokens(key);
|
|
11408
|
+
if (tokens.length === 0)
|
|
11409
|
+
return false;
|
|
11410
|
+
const normalized = tokens.join("-");
|
|
11411
|
+
if (normalized === "authorization" && value !== null && typeof value === "object") {
|
|
11412
|
+
return false;
|
|
11413
|
+
}
|
|
11414
|
+
if (NON_SECRET_SUFFIX.has(tokens.at(-1)))
|
|
11415
|
+
return false;
|
|
11416
|
+
return SECRET_COMPOUND.test(normalized) || tokens.some((token) => SECRET_TOKEN.test(token)) || normalized === "authorization";
|
|
11417
|
+
}
|
|
11418
|
+
function escapeRegExp(value) {
|
|
11419
|
+
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
11420
|
+
}
|
|
11421
|
+
function normalizedBlockedScalars(policy) {
|
|
11422
|
+
const identities = new Set;
|
|
11423
|
+
const values = [];
|
|
11424
|
+
for (const value of policy.blocked_scalars ?? []) {
|
|
11425
|
+
if (typeof value === "number" && !Number.isFinite(value))
|
|
11426
|
+
continue;
|
|
11427
|
+
if (typeof value === "string" && value.length === 0)
|
|
11428
|
+
continue;
|
|
11429
|
+
const identity = `${typeof value}:${String(value)}`;
|
|
11430
|
+
if (identities.has(identity))
|
|
11431
|
+
continue;
|
|
11432
|
+
identities.add(identity);
|
|
11433
|
+
values.push(value);
|
|
11434
|
+
}
|
|
11435
|
+
return values.sort((left, right) => String(right).length - String(left).length);
|
|
11436
|
+
}
|
|
11437
|
+
function replaceWithCount(value, pattern, replacement, count) {
|
|
11438
|
+
return value.replace(pattern, (...args) => {
|
|
11439
|
+
count.replacements += 1;
|
|
11440
|
+
if (typeof replacement === "string")
|
|
11441
|
+
return replacement;
|
|
11442
|
+
return replacement(...args.slice(0, -2));
|
|
11443
|
+
});
|
|
11444
|
+
}
|
|
11445
|
+
function redactKnownText(value, count) {
|
|
11446
|
+
let output = value;
|
|
11447
|
+
output = replaceWithCount(output, /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/gu, INDEXER_OUTPUT_REDACTION_MARKER, count);
|
|
11448
|
+
output = replaceWithCount(output, /(\bauthorization\s*:\s*(?:bearer|basic)\s+)[^\s,;]+/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
|
|
11449
|
+
output = replaceWithCount(output, /([a-z][a-z0-9+.-]*:\/\/)[^\s/@:]+:[^\s/@]+@/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}@`, count);
|
|
11450
|
+
output = replaceWithCount(output, /([?&](?:access_token|refresh_token|api_key|password|secret)=)[^&#\s]+/giu, (_match, prefix) => `${prefix}${INDEXER_OUTPUT_REDACTION_MARKER}`, count);
|
|
11451
|
+
const key = "(?:[A-Za-z0-9_.-]*(?:password|passwd|pwd|secret|token|credential|cookie)[A-Za-z0-9_.-]*|api[-_]?key|access[-_]?(?:key|token)|private[-_]?key|client[-_]?secret|authorization)";
|
|
11452
|
+
const assignment = `(?:=\\s*|:\\s+(?=\\S)|:\\s*(?=["']))`;
|
|
11453
|
+
output = replaceWithCount(output, new RegExp(`((?:["']?${key}["']?)\\s*${assignment})(?:"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|[^\\s,;}\\]]+)`, "giu"), (_match, prefix) => `${prefix}"${INDEXER_OUTPUT_REDACTION_MARKER}"`, count);
|
|
11454
|
+
return output;
|
|
11455
|
+
}
|
|
11456
|
+
function redactBlockedText(value, blocked, count) {
|
|
11457
|
+
let output = value;
|
|
11458
|
+
for (const scalar of blocked) {
|
|
11459
|
+
const pattern = typeof scalar === "number" ? new RegExp(`(?<![0-9.])${escapeRegExp(String(scalar))}(?![0-9.])`, "gu") : new RegExp(escapeRegExp(scalar), "gu");
|
|
11460
|
+
output = replaceWithCount(output, pattern, INDEXER_OUTPUT_REDACTION_MARKER, count);
|
|
11461
|
+
}
|
|
11462
|
+
return output;
|
|
11463
|
+
}
|
|
11464
|
+
function redactText(value, blocked, count) {
|
|
11465
|
+
return redactBlockedText(redactKnownText(value, count), blocked, count);
|
|
11466
|
+
}
|
|
11467
|
+
function blockedScalar(value, blocked) {
|
|
11468
|
+
return blocked.some((candidate) => typeof candidate === typeof value && Object.is(candidate, value));
|
|
11469
|
+
}
|
|
11470
|
+
function redactStructured(value, blocked, count, seen) {
|
|
11471
|
+
if (blockedScalar(value, blocked)) {
|
|
11472
|
+
count.replacements += 1;
|
|
11473
|
+
return INDEXER_OUTPUT_REDACTION_MARKER;
|
|
11474
|
+
}
|
|
11475
|
+
if (typeof value === "string")
|
|
11476
|
+
return redactText(value, blocked, count);
|
|
11477
|
+
if (value === null || typeof value !== "object")
|
|
11478
|
+
return value;
|
|
11479
|
+
if (seen.has(value))
|
|
11480
|
+
throw new TypeError("Indexer output redaction requires an acyclic value");
|
|
11481
|
+
seen.add(value);
|
|
11482
|
+
if (value instanceof Date) {
|
|
11483
|
+
const redacted2 = redactText(value.toISOString(), blocked, count);
|
|
11484
|
+
seen.delete(value);
|
|
11485
|
+
return redacted2;
|
|
11486
|
+
}
|
|
11487
|
+
if (value instanceof Error) {
|
|
11488
|
+
const redacted2 = {
|
|
11489
|
+
name: redactText(value.name, blocked, count),
|
|
11490
|
+
message: redactText(value.message, blocked, count)
|
|
11491
|
+
};
|
|
11492
|
+
seen.delete(value);
|
|
11493
|
+
return redacted2;
|
|
11494
|
+
}
|
|
11495
|
+
if (Array.isArray(value)) {
|
|
11496
|
+
const redacted2 = value.map((item) => redactStructured(item, blocked, count, seen));
|
|
11497
|
+
seen.delete(value);
|
|
11498
|
+
return redacted2;
|
|
11499
|
+
}
|
|
11500
|
+
const redacted = {};
|
|
11501
|
+
for (const [key, item] of Object.entries(value)) {
|
|
11502
|
+
const safeKey = redactText(key, blocked, count);
|
|
11503
|
+
if (sensitiveKey(key, item)) {
|
|
11504
|
+
count.replacements += 1;
|
|
11505
|
+
redacted[safeKey] = INDEXER_OUTPUT_REDACTION_MARKER;
|
|
11506
|
+
} else {
|
|
11507
|
+
redacted[safeKey] = redactStructured(item, blocked, count, seen);
|
|
11508
|
+
}
|
|
11509
|
+
}
|
|
11510
|
+
seen.delete(value);
|
|
11511
|
+
return redacted;
|
|
11512
|
+
}
|
|
11513
|
+
function redactIndexerOutput(input) {
|
|
11514
|
+
const count = { replacements: 0 };
|
|
11515
|
+
const blocked = normalizedBlockedScalars(input.policy ?? {});
|
|
11516
|
+
const value = typeof input.value === "string" ? redactText(input.value, blocked, count) : redactStructured(input.value, blocked, count, new WeakSet);
|
|
11517
|
+
return {
|
|
11518
|
+
value,
|
|
11519
|
+
redacted: count.replacements > 0,
|
|
11520
|
+
replacement_count: count.replacements
|
|
11521
|
+
};
|
|
11522
|
+
}
|
|
11523
|
+
function assertIndexerOutputSafe(input) {
|
|
11524
|
+
const result = redactIndexerOutput(input);
|
|
11525
|
+
if (result.redacted) {
|
|
11526
|
+
throw new TypeError(`Indexer ${input.channel} was blocked by the common output redaction boundary`);
|
|
11527
|
+
}
|
|
11528
|
+
return input.value;
|
|
11529
|
+
}
|
|
11530
|
+
|
|
11531
|
+
// ../core/src/schemas/indexerEvidenceAdapterSchema.ts
|
|
11532
|
+
var digestSchema = exports_external.string().regex(/^sha256:[a-f0-9]{64}$/u);
|
|
11533
|
+
var idSchema = exports_external.string().regex(/^[a-z0-9][a-z0-9._/-]*$/u).superRefine((value, context) => {
|
|
11534
|
+
if (value.split("/").some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
|
|
11535
|
+
context.addIssue({
|
|
11536
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11537
|
+
message: "must not contain empty, current-directory, or parent-directory segments"
|
|
11538
|
+
});
|
|
11539
|
+
}
|
|
11540
|
+
});
|
|
11541
|
+
var semverSchema = exports_external.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u);
|
|
11542
|
+
var canonicalRefSchema = exports_external.string().regex(/^[a-z][a-z0-9.-]*:[A-Za-z0-9][A-Za-z0-9._~:/#@+-]*$/u);
|
|
11543
|
+
var packageCoordinateSchema = exports_external.string().regex(/^(?:@[a-z0-9._-]+\/)?[a-z0-9][a-z0-9._-]*$/u);
|
|
11544
|
+
var portablePathSchema = exports_external.string().superRefine((value, context) => {
|
|
11545
|
+
const segments = value.split("/");
|
|
11546
|
+
if (value.length === 0 || value.includes("\x00") || value.includes("\\") || value.startsWith("/") || /^[A-Za-z]:\//u.test(value) || segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
|
|
11547
|
+
context.addIssue({
|
|
11548
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11549
|
+
message: "must be a portable relative path"
|
|
11550
|
+
});
|
|
11551
|
+
}
|
|
11552
|
+
});
|
|
11553
|
+
function addDuplicateIssues(values, context, field) {
|
|
11554
|
+
const seen = new Set;
|
|
11555
|
+
values.forEach((value, index) => {
|
|
11556
|
+
if (seen.has(value)) {
|
|
11557
|
+
context.addIssue({
|
|
11558
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11559
|
+
message: `${field} must not contain duplicate value ${value}`,
|
|
11560
|
+
path: [index]
|
|
11561
|
+
});
|
|
11562
|
+
}
|
|
11563
|
+
seen.add(value);
|
|
11564
|
+
});
|
|
11565
|
+
}
|
|
11566
|
+
var adapterIdentitySchema = exports_external.object({
|
|
11567
|
+
id: idSchema,
|
|
11568
|
+
package: packageCoordinateSchema,
|
|
11569
|
+
export: exports_external.string().regex(/^[A-Za-z_$][A-Za-z0-9_$.-]*$/u),
|
|
11570
|
+
version: semverSchema,
|
|
11571
|
+
digest: digestSchema
|
|
11572
|
+
}).strict();
|
|
11573
|
+
var adapterLocatorSchema = exports_external.object({
|
|
11574
|
+
source_ref: canonicalRefSchema,
|
|
11575
|
+
module_ref: canonicalRefSchema.nullable(),
|
|
11576
|
+
normalized_path: portablePathSchema,
|
|
11577
|
+
qualified_item_path: exports_external.string().min(1).max(1024),
|
|
11578
|
+
signature_digest: digestSchema
|
|
11579
|
+
}).strict();
|
|
11580
|
+
var indexerEvidenceAdapterFactSchema = exports_external.object({
|
|
11581
|
+
fact_ref: canonicalRefSchema,
|
|
11582
|
+
kind: idSchema,
|
|
11583
|
+
locator: adapterLocatorSchema,
|
|
11584
|
+
payload_digest: digestSchema,
|
|
11585
|
+
denominator: exports_external.enum(["none", "eligible-file", "loc", "symbol", "protocol-item"])
|
|
11586
|
+
}).strict();
|
|
11587
|
+
var indexerEvidenceAdapterFileSchema = exports_external.object({
|
|
11588
|
+
file_ref: canonicalRefSchema,
|
|
11589
|
+
source_ref: canonicalRefSchema,
|
|
11590
|
+
module_ref: canonicalRefSchema.nullable(),
|
|
11591
|
+
normalized_path: portablePathSchema,
|
|
11592
|
+
role: exports_external.enum(["primary-owner", "enricher"]),
|
|
11593
|
+
coverage_tier: exports_external.enum(["ast-catalog", "lightweight-evidence"]),
|
|
11594
|
+
disposition: exports_external.enum(["analyzed", "unsupported", "excluded"]),
|
|
11595
|
+
facts: exports_external.array(indexerEvidenceAdapterFactSchema)
|
|
11596
|
+
}).strict().superRefine((value, context) => {
|
|
11597
|
+
addDuplicateIssues(value.facts.map((fact2) => fact2.fact_ref), context, "facts");
|
|
11598
|
+
if (value.disposition !== "analyzed" && value.facts.length > 0) {
|
|
11599
|
+
context.addIssue({
|
|
11600
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11601
|
+
message: "unsupported or excluded files cannot publish facts",
|
|
11602
|
+
path: ["facts"]
|
|
11603
|
+
});
|
|
11604
|
+
}
|
|
11605
|
+
if ((value.role === "enricher" || value.coverage_tier === "lightweight-evidence") && value.facts.some((fact2) => fact2.denominator !== "none")) {
|
|
11606
|
+
context.addIssue({
|
|
11607
|
+
code: exports_external.ZodIssueCode.custom,
|
|
11608
|
+
message: "enricher and lightweight evidence facts cannot contribute denominators",
|
|
11609
|
+
path: ["facts"]
|
|
11610
|
+
});
|
|
11611
|
+
}
|
|
11612
|
+
});
|
|
11613
|
+
var toolchainStepSchema = exports_external.object({
|
|
11614
|
+
step: idSchema,
|
|
11615
|
+
package: packageCoordinateSchema,
|
|
11616
|
+
export: exports_external.string().regex(/^[A-Za-z_$][A-Za-z0-9_$.-]*$/u),
|
|
11617
|
+
version: semverSchema,
|
|
11618
|
+
digest: digestSchema,
|
|
11619
|
+
capabilities: exports_external.array(idSchema).min(1),
|
|
11620
|
+
input_digest: digestSchema,
|
|
11621
|
+
output_digest: digestSchema
|
|
11622
|
+
}).strict().superRefine((value, context) => {
|
|
11623
|
+
addDuplicateIssues(value.capabilities, context, "capabilities");
|
|
11624
|
+
});
|
|
11625
|
+
var adapterDiagnosticSchema = exports_external.object({
|
|
11626
|
+
code: idSchema,
|
|
11627
|
+
fact_ref: canonicalRefSchema.optional(),
|
|
11628
|
+
severity: exports_external.enum(["info", "warning", "error"]),
|
|
11629
|
+
detail_digest: digestSchema
|
|
11630
|
+
}).strict();
|
|
11631
|
+
var indexerEvidenceAdapterResultSchema = exports_external.object({
|
|
11632
|
+
protocol: exports_external.literal("context.indexer.evidence-adapter-result/v1"),
|
|
11633
|
+
adapter: adapterIdentitySchema,
|
|
11634
|
+
authorized_scope: exports_external.object({
|
|
11635
|
+
source_ref: canonicalRefSchema,
|
|
11636
|
+
module_refs: exports_external.array(canonicalRefSchema),
|
|
11637
|
+
scope_digest: digestSchema
|
|
11638
|
+
}).strict(),
|
|
11639
|
+
input_digest: digestSchema,
|
|
11640
|
+
precedence: exports_external.number().int().nonnegative(),
|
|
11641
|
+
files: exports_external.array(indexerEvidenceAdapterFileSchema).min(1),
|
|
11642
|
+
diagnostics: exports_external.array(adapterDiagnosticSchema),
|
|
11643
|
+
toolchain: exports_external.array(toolchainStepSchema).min(1),
|
|
11644
|
+
output_digest: digestSchema
|
|
11645
|
+
}).strict().superRefine((value, context) => {
|
|
11646
|
+
addDuplicateIssues(value.authorized_scope.module_refs, context, "authorized_scope.module_refs");
|
|
11647
|
+
addDuplicateIssues(value.files.map((file) => file.file_ref), context, "files");
|
|
11648
|
+
addDuplicateIssues(value.toolchain.map((step) => step.step), context, "toolchain");
|
|
11649
|
+
});
|
|
11650
|
+
var FACT_PAYLOADS = new WeakMap;
|
|
11651
|
+
function canonicalFactPayload(value, seen = new WeakSet, path = "$") {
|
|
11652
|
+
if (value === null || typeof value === "boolean" || typeof value === "string") {
|
|
11653
|
+
return value;
|
|
11654
|
+
}
|
|
11655
|
+
if (typeof value === "number") {
|
|
11656
|
+
if (!Number.isFinite(value)) {
|
|
11657
|
+
throw new TypeError("Indexer Evidence Adapter fact payload numbers must be finite");
|
|
11658
|
+
}
|
|
11659
|
+
return value;
|
|
11660
|
+
}
|
|
11661
|
+
if (typeof value !== "object") {
|
|
11662
|
+
throw new TypeError(`Indexer Evidence Adapter fact payload ${path} must contain only JSON values`);
|
|
11663
|
+
}
|
|
11664
|
+
if (seen.has(value)) {
|
|
11665
|
+
throw new TypeError(`Indexer Evidence Adapter fact payload ${path} must be acyclic`);
|
|
11666
|
+
}
|
|
11667
|
+
seen.add(value);
|
|
11668
|
+
if (Array.isArray(value)) {
|
|
11669
|
+
const output2 = value.map((item, index) => canonicalFactPayload(item, seen, `${path}[${index}]`));
|
|
11670
|
+
seen.delete(value);
|
|
11671
|
+
return output2;
|
|
11672
|
+
}
|
|
11673
|
+
if (Object.prototype.toString.call(value) !== "[object Object]") {
|
|
11674
|
+
throw new TypeError(`Indexer Evidence Adapter fact payload ${path} must use plain JSON objects; received ${Object.prototype.toString.call(value)}`);
|
|
11675
|
+
}
|
|
11676
|
+
const output = {};
|
|
11677
|
+
for (const [key, item] of Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0)) {
|
|
11678
|
+
output[key] = canonicalFactPayload(item, seen, `${path}.${key}`);
|
|
11679
|
+
}
|
|
11680
|
+
seen.delete(value);
|
|
11681
|
+
return output;
|
|
11682
|
+
}
|
|
11683
|
+
function canonicalize(value) {
|
|
11684
|
+
if (Array.isArray(value))
|
|
11685
|
+
return value.map(canonicalize);
|
|
11686
|
+
if (value !== null && typeof value === "object") {
|
|
11687
|
+
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).map(([key, item]) => [key, canonicalize(item)]));
|
|
11688
|
+
}
|
|
11689
|
+
return value;
|
|
11690
|
+
}
|
|
11691
|
+
function indexerEvidenceAdapterProtocolDigest(value) {
|
|
11692
|
+
const canonical = JSON.stringify(canonicalize(value));
|
|
11693
|
+
return `sha256:${createHash("sha256").update(canonical).digest("hex")}`;
|
|
11694
|
+
}
|
|
11695
|
+
function indexerEvidenceAdapterFileRef(input) {
|
|
11696
|
+
return `adapter-file:${indexerEvidenceAdapterProtocolDigest(input)}`;
|
|
11697
|
+
}
|
|
11698
|
+
function indexerEvidenceAdapterFactRef(input) {
|
|
11699
|
+
return `adapter-fact:${indexerEvidenceAdapterProtocolDigest(input)}`;
|
|
11700
|
+
}
|
|
11701
|
+
function createIndexerEvidenceAdapterFact(input) {
|
|
11702
|
+
const payload = canonicalFactPayload(input.payload);
|
|
11703
|
+
const qualifiedItemPath = input.qualified_item_path.length <= 1024 ? input.qualified_item_path : `${input.qualified_item_path.slice(0, 950)}#${indexerEvidenceAdapterProtocolDigest(input.qualified_item_path)}`;
|
|
11704
|
+
const locator = {
|
|
11705
|
+
source_ref: input.source_ref,
|
|
11706
|
+
module_ref: input.module_ref,
|
|
11707
|
+
normalized_path: input.normalized_path,
|
|
11708
|
+
qualified_item_path: qualifiedItemPath,
|
|
11709
|
+
signature_digest: indexerEvidenceAdapterProtocolDigest(input.signature)
|
|
11710
|
+
};
|
|
11711
|
+
const fact2 = {
|
|
11712
|
+
fact_ref: indexerEvidenceAdapterFactRef({ ...locator, kind: input.kind }),
|
|
11713
|
+
kind: input.kind,
|
|
11714
|
+
locator,
|
|
11715
|
+
payload_digest: indexerEvidenceAdapterProtocolDigest(payload),
|
|
11716
|
+
denominator: input.denominator
|
|
11717
|
+
};
|
|
11718
|
+
FACT_PAYLOADS.set(fact2, payload);
|
|
11719
|
+
return fact2;
|
|
11720
|
+
}
|
|
11721
|
+
function indexerEvidenceAdapterOutputDigest(value) {
|
|
11722
|
+
return indexerEvidenceAdapterProtocolDigest(value);
|
|
11723
|
+
}
|
|
11724
|
+
function compareCanonicalText(left, right) {
|
|
11725
|
+
if (left < right)
|
|
11726
|
+
return -1;
|
|
11727
|
+
if (left > right)
|
|
11728
|
+
return 1;
|
|
11729
|
+
return 0;
|
|
11730
|
+
}
|
|
11731
|
+
function buildIndexerEvidenceAdapterResult(input) {
|
|
11732
|
+
const canonical = {
|
|
11733
|
+
...input,
|
|
11734
|
+
authorized_scope: {
|
|
11735
|
+
...input.authorized_scope,
|
|
11736
|
+
module_refs: [...input.authorized_scope.module_refs].sort(compareCanonicalText)
|
|
11737
|
+
},
|
|
11738
|
+
files: input.files.map((file) => ({
|
|
11739
|
+
...file,
|
|
11740
|
+
facts: [...file.facts].sort((left, right) => compareCanonicalText(left.fact_ref, right.fact_ref))
|
|
11741
|
+
})).sort((left, right) => compareCanonicalText(left.file_ref, right.file_ref)),
|
|
11742
|
+
diagnostics: [...input.diagnostics].sort((left, right) => compareCanonicalText(left.fact_ref ?? "", right.fact_ref ?? "") || compareCanonicalText(left.code, right.code) || compareCanonicalText(left.severity, right.severity) || compareCanonicalText(left.detail_digest, right.detail_digest)),
|
|
11743
|
+
toolchain: input.toolchain.map((step) => ({
|
|
11744
|
+
...step,
|
|
11745
|
+
capabilities: [...step.capabilities].sort(compareCanonicalText)
|
|
11746
|
+
}))
|
|
11747
|
+
};
|
|
11748
|
+
const payloads = new Map;
|
|
11749
|
+
for (const file of canonical.files) {
|
|
11750
|
+
for (const fact2 of file.facts) {
|
|
11751
|
+
const payload = FACT_PAYLOADS.get(fact2);
|
|
11752
|
+
if (payload !== undefined)
|
|
11753
|
+
payloads.set(fact2.fact_ref, payload);
|
|
11754
|
+
}
|
|
11755
|
+
}
|
|
11756
|
+
const parsed = indexerEvidenceAdapterResultSchema.parse({
|
|
11757
|
+
...canonical,
|
|
11758
|
+
output_digest: indexerEvidenceAdapterOutputDigest(canonical)
|
|
11759
|
+
});
|
|
11760
|
+
for (const file of parsed.files) {
|
|
11761
|
+
for (const fact2 of file.facts) {
|
|
11762
|
+
const payload = payloads.get(fact2.fact_ref);
|
|
11763
|
+
if (payload !== undefined)
|
|
11764
|
+
FACT_PAYLOADS.set(fact2, payload);
|
|
11765
|
+
}
|
|
11766
|
+
}
|
|
11767
|
+
return assertIndexerOutputSafe({ channel: "success-payload", value: parsed });
|
|
11768
|
+
}
|
|
11378
11769
|
// ../core/src/errors/httpStatus.ts
|
|
11379
11770
|
var ERROR_CODE_HTTP_STATUS = {
|
|
11380
11771
|
["VALIDATION_FAILED" /* VALIDATION_FAILED */]: 400,
|
|
@@ -11490,7 +11881,15 @@ var DEFAULT_CONTENT_TYPES = [
|
|
|
11490
11881
|
{
|
|
11491
11882
|
id: "typescript",
|
|
11492
11883
|
category: "code",
|
|
11493
|
-
match: { extensions: [".ts", ".tsx"] },
|
|
11884
|
+
match: { extensions: [".ts", ".tsx", ".mts", ".cts"] },
|
|
11885
|
+
cas: { encoding: "utf8", hashInput: "content" },
|
|
11886
|
+
pipeline: { digest: ["ast", "summary"], extraction: ["entities", "relations"] },
|
|
11887
|
+
display: { icon: "\uD83D\uDCDC", renderer: "code" }
|
|
11888
|
+
},
|
|
11889
|
+
{
|
|
11890
|
+
id: "javascript",
|
|
11891
|
+
category: "code",
|
|
11892
|
+
match: { extensions: [".js", ".jsx", ".mjs", ".cjs"] },
|
|
11494
11893
|
cas: { encoding: "utf8", hashInput: "content" },
|
|
11495
11894
|
pipeline: { digest: ["ast", "summary"], extraction: ["entities", "relations"] },
|
|
11496
11895
|
display: { icon: "\uD83D\uDCDC", renderer: "code" }
|
|
@@ -11951,6 +12350,13 @@ class GoPlugin {
|
|
|
11951
12350
|
id = "c4a-extract-go";
|
|
11952
12351
|
languages = ["go"];
|
|
11953
12352
|
packageManagers = ["go"];
|
|
12353
|
+
coverageTier = "ast-catalog";
|
|
12354
|
+
capabilities = [
|
|
12355
|
+
"go-ast",
|
|
12356
|
+
"go-call-relations",
|
|
12357
|
+
"go-http-routes",
|
|
12358
|
+
"parser.go"
|
|
12359
|
+
];
|
|
11954
12360
|
manifestTypes = ["go.mod"];
|
|
11955
12361
|
#lastDetection = null;
|
|
11956
12362
|
canHandle(source) {
|
|
@@ -12038,6 +12444,16 @@ class GoPlugin {
|
|
|
12038
12444
|
files,
|
|
12039
12445
|
symbols,
|
|
12040
12446
|
relations,
|
|
12447
|
+
coverage: {
|
|
12448
|
+
tier: this.coverageTier,
|
|
12449
|
+
capabilities: [...this.capabilities],
|
|
12450
|
+
files: files.map((file) => ({
|
|
12451
|
+
path: file.path,
|
|
12452
|
+
disposition: "analyzed",
|
|
12453
|
+
diagnosticCodes: []
|
|
12454
|
+
})),
|
|
12455
|
+
diagnostics: []
|
|
12456
|
+
},
|
|
12041
12457
|
stats: {
|
|
12042
12458
|
files: files.length,
|
|
12043
12459
|
lines: files.reduce((sum, file) => sum + file.lines, 0),
|
|
@@ -12133,8 +12549,905 @@ async function indexGoRepository(repositoryRoot, options = {}) {
|
|
|
12133
12549
|
files
|
|
12134
12550
|
};
|
|
12135
12551
|
}
|
|
12552
|
+
// ../extract/src/types.ts
|
|
12553
|
+
var symbolKindSchema2 = exports_external.enum(Object.values(SymbolKind));
|
|
12554
|
+
var visibilitySchema2 = exports_external.enum(Object.values(Visibility));
|
|
12555
|
+
var relationTypeSchema = exports_external.enum([
|
|
12556
|
+
"imports" /* Imports */,
|
|
12557
|
+
"imports_type" /* ImportsType */,
|
|
12558
|
+
"calls" /* Calls */,
|
|
12559
|
+
"extends" /* Extends */,
|
|
12560
|
+
"implements" /* Implements */,
|
|
12561
|
+
"param_type" /* ParamType */,
|
|
12562
|
+
"return_type" /* ReturnType */,
|
|
12563
|
+
"of_type" /* OfType */,
|
|
12564
|
+
"depends_on" /* DependsOn */,
|
|
12565
|
+
"contains" /* Contains */
|
|
12566
|
+
]);
|
|
12567
|
+
var relationSourceSchema = exports_external.enum([
|
|
12568
|
+
"ast" /* Ast */,
|
|
12569
|
+
"doc" /* Doc */,
|
|
12570
|
+
"manual" /* Manual */
|
|
12571
|
+
]);
|
|
12572
|
+
var packageKindSchema2 = exports_external.enum(Object.values(PackageKind));
|
|
12573
|
+
var symbolParamSchema = exports_external.object({
|
|
12574
|
+
name: exports_external.string().min(1),
|
|
12575
|
+
type: exports_external.string().min(1).nullable()
|
|
12576
|
+
});
|
|
12577
|
+
var symbolInfoSchema = exports_external.lazy(() => exports_external.object({
|
|
12578
|
+
name: exports_external.string().min(1),
|
|
12579
|
+
kind: symbolKindSchema2,
|
|
12580
|
+
visibility: visibilitySchema2,
|
|
12581
|
+
file: exports_external.string().min(1),
|
|
12582
|
+
line: exports_external.number().int().positive(),
|
|
12583
|
+
endLine: exports_external.number().int().positive(),
|
|
12584
|
+
members: exports_external.array(symbolInfoSchema).optional(),
|
|
12585
|
+
params: exports_external.array(symbolParamSchema).optional(),
|
|
12586
|
+
returnType: exports_external.string().min(1).nullable().optional(),
|
|
12587
|
+
typeAnnotation: exports_external.string().min(1).nullable().optional(),
|
|
12588
|
+
extends: exports_external.string().min(1).nullable().optional(),
|
|
12589
|
+
implements: exports_external.array(exports_external.string().min(1)).optional(),
|
|
12590
|
+
doc: exports_external.string().nullable().optional(),
|
|
12591
|
+
propsType: exports_external.string().min(1).nullable().optional(),
|
|
12592
|
+
unionValues: exports_external.array(exports_external.string()).optional(),
|
|
12593
|
+
initializer: exports_external.string().min(1).nullable().optional(),
|
|
12594
|
+
signature: exports_external.string().min(1).nullable().optional()
|
|
12595
|
+
}));
|
|
12596
|
+
var relationInfoSchema = exports_external.object({
|
|
12597
|
+
type: relationTypeSchema,
|
|
12598
|
+
from: exports_external.string().min(1),
|
|
12599
|
+
to: exports_external.string().min(1),
|
|
12600
|
+
isExternal: exports_external.boolean(),
|
|
12601
|
+
grounding: groundingSchema,
|
|
12602
|
+
confidence: exports_external.number().min(0).max(1),
|
|
12603
|
+
source: relationSourceSchema,
|
|
12604
|
+
line: exports_external.number().int().positive().optional()
|
|
12605
|
+
});
|
|
12606
|
+
var fileInfoSchema = exports_external.object({
|
|
12607
|
+
path: exports_external.string().min(1),
|
|
12608
|
+
language: exports_external.string().min(1),
|
|
12609
|
+
lines: exports_external.number().int().nonnegative()
|
|
12610
|
+
});
|
|
12611
|
+
var extractionDiagnosticSchema = exports_external.object({
|
|
12612
|
+
code: exports_external.string().min(1),
|
|
12613
|
+
severity: exports_external.enum(["info", "warning", "error"]),
|
|
12614
|
+
file: exports_external.string().min(1),
|
|
12615
|
+
line: exports_external.number().int().positive(),
|
|
12616
|
+
column: exports_external.number().int().positive()
|
|
12617
|
+
});
|
|
12618
|
+
var extractionCoverageSchema = exports_external.object({
|
|
12619
|
+
tier: exports_external.enum(["ast-catalog", "lightweight-evidence"]),
|
|
12620
|
+
capabilities: exports_external.array(exports_external.string().min(1)),
|
|
12621
|
+
files: exports_external.array(exports_external.object({
|
|
12622
|
+
path: exports_external.string().min(1),
|
|
12623
|
+
disposition: exports_external.enum(["analyzed", "unsupported", "excluded"]),
|
|
12624
|
+
diagnosticCodes: exports_external.array(exports_external.string().min(1))
|
|
12625
|
+
})),
|
|
12626
|
+
diagnostics: exports_external.array(extractionDiagnosticSchema)
|
|
12627
|
+
});
|
|
12628
|
+
var extractionMetaSchema = exports_external.object({
|
|
12629
|
+
extractedAt: exports_external.string().datetime(),
|
|
12630
|
+
pluginId: exports_external.string().min(1),
|
|
12631
|
+
commitHash: exports_external.string().min(1).nullable(),
|
|
12632
|
+
language: exports_external.string().min(1)
|
|
12633
|
+
});
|
|
12634
|
+
var extractionPackageSchema = exports_external.object({
|
|
12635
|
+
name: exports_external.string().min(1),
|
|
12636
|
+
kind: packageKindSchema2,
|
|
12637
|
+
language: exports_external.string().min(1),
|
|
12638
|
+
version: exports_external.string().min(1).optional()
|
|
12639
|
+
});
|
|
12640
|
+
var extractionStatsSchema = exports_external.object({
|
|
12641
|
+
files: exports_external.number().int().nonnegative(),
|
|
12642
|
+
lines: exports_external.number().int().nonnegative(),
|
|
12643
|
+
exportedSymbols: exports_external.number().int().nonnegative(),
|
|
12644
|
+
internalSymbols: exports_external.number().int().nonnegative(),
|
|
12645
|
+
relations: exports_external.number().int().nonnegative()
|
|
12646
|
+
});
|
|
12647
|
+
var extractionResultSchema = exports_external.object({
|
|
12648
|
+
version: exports_external.literal("2"),
|
|
12649
|
+
meta: extractionMetaSchema,
|
|
12650
|
+
package: extractionPackageSchema,
|
|
12651
|
+
files: exports_external.array(fileInfoSchema),
|
|
12652
|
+
symbols: exports_external.array(symbolInfoSchema),
|
|
12653
|
+
relations: exports_external.array(relationInfoSchema),
|
|
12654
|
+
coverage: extractionCoverageSchema.optional(),
|
|
12655
|
+
stats: extractionStatsSchema
|
|
12656
|
+
});
|
|
12657
|
+
var digestStatsSchema = exports_external.object({
|
|
12658
|
+
files: exports_external.number().int().nonnegative(),
|
|
12659
|
+
lines: exports_external.number().int().nonnegative(),
|
|
12660
|
+
exported_count: exports_external.number().int().nonnegative(),
|
|
12661
|
+
internal_count: exports_external.number().int().nonnegative(),
|
|
12662
|
+
relations: exports_external.number().int().nonnegative()
|
|
12663
|
+
});
|
|
12664
|
+
var digestDataSchema = exports_external.object({
|
|
12665
|
+
version: exports_external.literal("2"),
|
|
12666
|
+
meta: extractionMetaSchema,
|
|
12667
|
+
package: extractionPackageSchema,
|
|
12668
|
+
files: exports_external.array(fileInfoSchema),
|
|
12669
|
+
symbols: exports_external.array(symbolInfoSchema),
|
|
12670
|
+
relations: exports_external.array(relationInfoSchema),
|
|
12671
|
+
coverage: extractionCoverageSchema.optional(),
|
|
12672
|
+
stats: digestStatsSchema
|
|
12673
|
+
});
|
|
12674
|
+
var symbolDiffSchema = exports_external.object({
|
|
12675
|
+
added: exports_external.array(exports_external.string().min(1)),
|
|
12676
|
+
removed: exports_external.array(exports_external.string().min(1))
|
|
12677
|
+
});
|
|
12678
|
+
// ../extract/src/protocol.ts
|
|
12679
|
+
var packageKindSchema3 = exports_external.enum(Object.values(PackageKind));
|
|
12680
|
+
var manifestTypeSchema = exports_external.enum([
|
|
12681
|
+
"package.json",
|
|
12682
|
+
"pyproject.toml",
|
|
12683
|
+
"Cargo.toml",
|
|
12684
|
+
"go.mod",
|
|
12685
|
+
"pom.xml"
|
|
12686
|
+
]);
|
|
12687
|
+
var entryFileSchema = exports_external.object({
|
|
12688
|
+
path: exports_external.string().min(1),
|
|
12689
|
+
subpath: exports_external.string().min(1),
|
|
12690
|
+
type: exports_external.enum(["library", "cli", "service", "webapp"])
|
|
12691
|
+
});
|
|
12692
|
+
var manifestInfoSchema = exports_external.object({
|
|
12693
|
+
type: manifestTypeSchema,
|
|
12694
|
+
path: exports_external.string().min(1),
|
|
12695
|
+
content: exports_external.record(exports_external.unknown())
|
|
12696
|
+
});
|
|
12697
|
+
var sourceInfoSchema = exports_external.object({
|
|
12698
|
+
path: exports_external.string().min(1),
|
|
12699
|
+
manifests: exports_external.array(manifestInfoSchema),
|
|
12700
|
+
language: exports_external.string().min(1).optional()
|
|
12701
|
+
});
|
|
12702
|
+
var entryDetectionResultSchema = exports_external.lazy(() => exports_external.object({
|
|
12703
|
+
package: exports_external.object({
|
|
12704
|
+
name: exports_external.string().min(1),
|
|
12705
|
+
kind: packageKindSchema3,
|
|
12706
|
+
language: exports_external.string().min(1),
|
|
12707
|
+
version: exports_external.string().min(1).optional()
|
|
12708
|
+
}),
|
|
12709
|
+
entries: exports_external.array(entryFileSchema),
|
|
12710
|
+
subPackages: exports_external.array(entryDetectionResultSchema).optional()
|
|
12711
|
+
}));
|
|
12712
|
+
var patternDetectionResultSchema = exports_external.object({
|
|
12713
|
+
endpoints: exports_external.array(exports_external.object({
|
|
12714
|
+
handler: exports_external.string().min(1),
|
|
12715
|
+
method: exports_external.string().min(1),
|
|
12716
|
+
path: exports_external.string().min(1),
|
|
12717
|
+
file: exports_external.string().min(1),
|
|
12718
|
+
line: exports_external.number().int().positive()
|
|
12719
|
+
})).optional(),
|
|
12720
|
+
implicitDeps: exports_external.array(exports_external.object({
|
|
12721
|
+
verb: exports_external.enum(["produce", "consume", "depends_on", "serve"]),
|
|
12722
|
+
target: exports_external.string().min(1),
|
|
12723
|
+
file: exports_external.string().min(1),
|
|
12724
|
+
line: exports_external.number().int().positive()
|
|
12725
|
+
})).optional(),
|
|
12726
|
+
configRefs: exports_external.array(exports_external.object({
|
|
12727
|
+
key: exports_external.string().min(1),
|
|
12728
|
+
file: exports_external.string().min(1),
|
|
12729
|
+
line: exports_external.number().int().positive()
|
|
12730
|
+
})).optional()
|
|
12731
|
+
});
|
|
12732
|
+
// ../extract/src/registry.ts
|
|
12733
|
+
var MANIFEST_LANGUAGE_CANDIDATES = {
|
|
12734
|
+
"package.json": ["typescript", "tsx", "javascript", "jsx"],
|
|
12735
|
+
"pyproject.toml": ["python"],
|
|
12736
|
+
"Cargo.toml": ["rust"],
|
|
12737
|
+
"go.mod": ["go"],
|
|
12738
|
+
"pom.xml": ["java"]
|
|
12739
|
+
};
|
|
12740
|
+
|
|
12741
|
+
class ExtractionPluginRegistry {
|
|
12742
|
+
#plugins = [];
|
|
12743
|
+
register(plugin) {
|
|
12744
|
+
this.#plugins.push(plugin);
|
|
12745
|
+
}
|
|
12746
|
+
resolve(source) {
|
|
12747
|
+
const declaredLanguage = source.language?.toLowerCase();
|
|
12748
|
+
const manifestLanguages = new Set(source.manifests.flatMap((manifest) => MANIFEST_LANGUAGE_CANDIDATES[manifest.type] ?? []));
|
|
12749
|
+
const candidates = this.#plugins.filter((plugin) => {
|
|
12750
|
+
const pluginLanguages = plugin.languages.map((language) => language.toLowerCase());
|
|
12751
|
+
if (declaredLanguage) {
|
|
12752
|
+
return pluginLanguages.includes(declaredLanguage);
|
|
12753
|
+
}
|
|
12754
|
+
if (manifestLanguages.size === 0) {
|
|
12755
|
+
return true;
|
|
12756
|
+
}
|
|
12757
|
+
return pluginLanguages.some((language) => manifestLanguages.has(language));
|
|
12758
|
+
});
|
|
12759
|
+
for (const plugin of candidates) {
|
|
12760
|
+
if (plugin.canHandle(source)) {
|
|
12761
|
+
return plugin;
|
|
12762
|
+
}
|
|
12763
|
+
}
|
|
12764
|
+
return null;
|
|
12765
|
+
}
|
|
12766
|
+
list() {
|
|
12767
|
+
return [...this.#plugins];
|
|
12768
|
+
}
|
|
12769
|
+
}
|
|
12770
|
+
// ../extract/src/scanner.ts
|
|
12771
|
+
import { execFile } from "node:child_process";
|
|
12772
|
+
import { promisify } from "node:util";
|
|
12773
|
+
var execFileAsync = promisify(execFile);
|
|
12774
|
+
var SUPPORTED_EXTENSIONS = new Set([
|
|
12775
|
+
".ts",
|
|
12776
|
+
".tsx",
|
|
12777
|
+
".mts",
|
|
12778
|
+
".cts",
|
|
12779
|
+
".js",
|
|
12780
|
+
".jsx",
|
|
12781
|
+
".mjs",
|
|
12782
|
+
".cjs"
|
|
12783
|
+
]);
|
|
12784
|
+
var MANIFEST_FILES = [
|
|
12785
|
+
"package.json",
|
|
12786
|
+
"pyproject.toml",
|
|
12787
|
+
"setup.py",
|
|
12788
|
+
"go.mod",
|
|
12789
|
+
"Cargo.toml",
|
|
12790
|
+
"pom.xml",
|
|
12791
|
+
"build.gradle"
|
|
12792
|
+
];
|
|
12793
|
+
var MANIFEST_NAMES = new Set(MANIFEST_FILES.map((f) => f.toLowerCase()));
|
|
12794
|
+
// ../extract/src/runner.ts
|
|
12795
|
+
var pluginSpecSchema = exports_external.object({
|
|
12796
|
+
package: exports_external.string().min(1),
|
|
12797
|
+
exportName: exports_external.string().min(1).optional()
|
|
12798
|
+
});
|
|
12799
|
+
var entrySelectionSchema = exports_external.discriminatedUnion("mode", [
|
|
12800
|
+
exports_external.object({ mode: exports_external.literal("auto") }),
|
|
12801
|
+
exports_external.object({ mode: exports_external.literal("configured"), entries: exports_external.array(exports_external.string().min(1)) }),
|
|
12802
|
+
exports_external.object({ mode: exports_external.literal("scan") })
|
|
12803
|
+
]);
|
|
12804
|
+
var codeExtractRunnerInputSchema = exports_external.object({
|
|
12805
|
+
repoPath: exports_external.string().min(1),
|
|
12806
|
+
modules: exports_external.array(exports_external.string().min(1)).optional(),
|
|
12807
|
+
ref: exports_external.string().min(1).optional(),
|
|
12808
|
+
commitHash: exports_external.string().min(1).nullable().optional(),
|
|
12809
|
+
moduleCommits: exports_external.record(exports_external.string().nullable()).optional(),
|
|
12810
|
+
pathFilter: PathFilterConfigSchema.optional(),
|
|
12811
|
+
entrySelection: entrySelectionSchema.optional(),
|
|
12812
|
+
plugins: exports_external.array(pluginSpecSchema).min(1),
|
|
12813
|
+
snapshot: exports_external.object({
|
|
12814
|
+
sourceId: exports_external.string().min(1),
|
|
12815
|
+
sourceSlug: exports_external.string().min(1),
|
|
12816
|
+
snapshotId: exports_external.string().min(1),
|
|
12817
|
+
codeSnapshotContractVersion: exports_external.string().min(1),
|
|
12818
|
+
scriptHash: exports_external.string().min(1),
|
|
12819
|
+
toolchain: exports_external.object({
|
|
12820
|
+
manager_package: exports_external.string().min(1),
|
|
12821
|
+
manager_version: exports_external.string().min(1),
|
|
12822
|
+
runner_package: exports_external.string().min(1),
|
|
12823
|
+
runner_package_version: exports_external.string().min(1),
|
|
12824
|
+
runner_bin: exports_external.string().min(1),
|
|
12825
|
+
plugin_package: exports_external.string().min(1),
|
|
12826
|
+
plugin_package_version: exports_external.string().min(1),
|
|
12827
|
+
plugin_export: exports_external.string().min(1)
|
|
12828
|
+
}),
|
|
12829
|
+
sourceCommit: exports_external.string().min(1).nullable().optional(),
|
|
12830
|
+
versionPolicy: exports_external.enum(["package-version", "module-commit", "explicit", "none"]).optional(),
|
|
12831
|
+
originPath: exports_external.string().min(1).optional(),
|
|
12832
|
+
worktreeContentHash: exports_external.string().min(1).optional()
|
|
12833
|
+
}).optional()
|
|
12834
|
+
});
|
|
12835
|
+
// ../extract/src/evidenceAdapter.ts
|
|
12836
|
+
function fact2(input) {
|
|
12837
|
+
return createIndexerEvidenceAdapterFact({
|
|
12838
|
+
source_ref: input.sourceRef,
|
|
12839
|
+
module_ref: input.moduleRef,
|
|
12840
|
+
normalized_path: input.normalizedPath,
|
|
12841
|
+
qualified_item_path: input.qualifiedItemPath,
|
|
12842
|
+
kind: input.kind,
|
|
12843
|
+
signature: input.signature,
|
|
12844
|
+
payload: input.payload,
|
|
12845
|
+
denominator: input.denominator
|
|
12846
|
+
});
|
|
12847
|
+
}
|
|
12848
|
+
function semanticExtractionPayload(extraction) {
|
|
12849
|
+
return {
|
|
12850
|
+
version: extraction.version,
|
|
12851
|
+
meta: {
|
|
12852
|
+
pluginId: extraction.meta.pluginId,
|
|
12853
|
+
commitHash: extraction.meta.commitHash,
|
|
12854
|
+
language: extraction.meta.language
|
|
12855
|
+
},
|
|
12856
|
+
package: extraction.package,
|
|
12857
|
+
files: extraction.files,
|
|
12858
|
+
symbols: extraction.symbols,
|
|
12859
|
+
relations: extraction.relations,
|
|
12860
|
+
coverage: extraction.coverage,
|
|
12861
|
+
stats: extraction.stats
|
|
12862
|
+
};
|
|
12863
|
+
}
|
|
12864
|
+
function relationSourceFile(relation, symbols) {
|
|
12865
|
+
const candidates = symbols.filter((symbol) => symbol.name === relation.from);
|
|
12866
|
+
if (candidates.length === 1)
|
|
12867
|
+
return candidates[0].file;
|
|
12868
|
+
if (relation.line !== undefined) {
|
|
12869
|
+
const containing = candidates.filter((symbol) => symbol.line <= relation.line && symbol.endLine >= relation.line);
|
|
12870
|
+
if (containing.length === 1)
|
|
12871
|
+
return containing[0].file;
|
|
12872
|
+
}
|
|
12873
|
+
return null;
|
|
12874
|
+
}
|
|
12875
|
+
function diagnosticPayload(diagnostic) {
|
|
12876
|
+
return {
|
|
12877
|
+
code: diagnostic.code,
|
|
12878
|
+
severity: diagnostic.severity,
|
|
12879
|
+
file: diagnostic.file,
|
|
12880
|
+
line: diagnostic.line,
|
|
12881
|
+
column: diagnostic.column
|
|
12882
|
+
};
|
|
12883
|
+
}
|
|
12884
|
+
function extractionResultToEvidenceAdapterResult(extraction, invocation) {
|
|
12885
|
+
const coverage = extraction.coverage;
|
|
12886
|
+
if (!coverage) {
|
|
12887
|
+
throw new TypeError("ExtractionResult coverage is required for Evidence Adapter Result conversion");
|
|
12888
|
+
}
|
|
12889
|
+
if (coverage.capabilities.length === 0) {
|
|
12890
|
+
throw new TypeError("ExtractionResult coverage must declare at least one parser capability");
|
|
12891
|
+
}
|
|
12892
|
+
const coverageByPath = new Map(coverage.files.map((file) => [file.path, file]));
|
|
12893
|
+
const fileInfoByPath = new Map(extraction.files.map((file) => [file.path, file]));
|
|
12894
|
+
for (const file of extraction.files) {
|
|
12895
|
+
if (!coverageByPath.has(file.path)) {
|
|
12896
|
+
throw new TypeError(`ExtractionResult file ${file.path} has no coverage disposition`);
|
|
12897
|
+
}
|
|
12898
|
+
}
|
|
12899
|
+
for (const symbol of extraction.symbols) {
|
|
12900
|
+
const disposition = coverageByPath.get(symbol.file)?.disposition;
|
|
12901
|
+
if (disposition !== "analyzed") {
|
|
12902
|
+
throw new TypeError(`ExtractionResult symbol ${symbol.name} belongs to a file without analyzed disposition`);
|
|
12903
|
+
}
|
|
12904
|
+
}
|
|
12905
|
+
const role = invocation.role ?? "primary-owner";
|
|
12906
|
+
const ownsDenominators = role === "primary-owner" && coverage.tier === "ast-catalog";
|
|
12907
|
+
const generatedDiagnostics = [];
|
|
12908
|
+
const relationsByFile = new Map;
|
|
12909
|
+
for (const relation of extraction.relations) {
|
|
12910
|
+
const file = relationSourceFile(relation, extraction.symbols);
|
|
12911
|
+
if (file === null || coverageByPath.get(file)?.disposition !== "analyzed") {
|
|
12912
|
+
generatedDiagnostics.push({
|
|
12913
|
+
code: "relation-locator-unresolved",
|
|
12914
|
+
severity: "warning",
|
|
12915
|
+
detail_digest: indexerEvidenceAdapterProtocolDigest(relation)
|
|
12916
|
+
});
|
|
12917
|
+
continue;
|
|
12918
|
+
}
|
|
12919
|
+
const current = relationsByFile.get(file) ?? [];
|
|
12920
|
+
current.push(relation);
|
|
12921
|
+
relationsByFile.set(file, current);
|
|
12922
|
+
}
|
|
12923
|
+
const files = coverage.files.map((coverageFile) => {
|
|
12924
|
+
const normalizedPath = coverageFile.path;
|
|
12925
|
+
const fileRef = indexerEvidenceAdapterFileRef({
|
|
12926
|
+
source_ref: invocation.authorized_scope.source_ref,
|
|
12927
|
+
module_ref: invocation.module_ref,
|
|
12928
|
+
normalized_path: normalizedPath
|
|
12929
|
+
});
|
|
12930
|
+
const fileInfo = fileInfoByPath.get(normalizedPath);
|
|
12931
|
+
if (coverageFile.disposition === "analyzed" && !fileInfo) {
|
|
12932
|
+
throw new TypeError(`Analyzed file ${normalizedPath} has no ExtractionResult file metadata`);
|
|
12933
|
+
}
|
|
12934
|
+
const facts = [];
|
|
12935
|
+
if (coverageFile.disposition === "analyzed" && fileInfo) {
|
|
12936
|
+
facts.push(fact2({
|
|
12937
|
+
sourceRef: invocation.authorized_scope.source_ref,
|
|
12938
|
+
moduleRef: invocation.module_ref,
|
|
12939
|
+
normalizedPath,
|
|
12940
|
+
qualifiedItemPath: "file",
|
|
12941
|
+
kind: "source-file",
|
|
12942
|
+
signature: { path: normalizedPath, language: fileInfo.language },
|
|
12943
|
+
payload: fileInfo,
|
|
12944
|
+
denominator: ownsDenominators ? "eligible-file" : "none"
|
|
12945
|
+
}));
|
|
12946
|
+
facts.push(fact2({
|
|
12947
|
+
sourceRef: invocation.authorized_scope.source_ref,
|
|
12948
|
+
moduleRef: invocation.module_ref,
|
|
12949
|
+
normalizedPath,
|
|
12950
|
+
qualifiedItemPath: "loc",
|
|
12951
|
+
kind: "source-loc",
|
|
12952
|
+
signature: { path: normalizedPath },
|
|
12953
|
+
payload: { lines: fileInfo.lines },
|
|
12954
|
+
denominator: ownsDenominators ? "loc" : "none"
|
|
12955
|
+
}));
|
|
12956
|
+
for (const symbol of extraction.symbols.filter((item) => item.file === normalizedPath)) {
|
|
12957
|
+
facts.push(fact2({
|
|
12958
|
+
sourceRef: invocation.authorized_scope.source_ref,
|
|
12959
|
+
moduleRef: invocation.module_ref,
|
|
12960
|
+
normalizedPath,
|
|
12961
|
+
qualifiedItemPath: `symbol:${symbol.kind}:${symbol.name}@${symbol.line}`,
|
|
12962
|
+
kind: "code-symbol",
|
|
12963
|
+
signature: {
|
|
12964
|
+
name: symbol.name,
|
|
12965
|
+
kind: symbol.kind,
|
|
12966
|
+
signature: symbol.signature ?? null,
|
|
12967
|
+
params: symbol.params ?? null,
|
|
12968
|
+
returnType: symbol.returnType ?? null,
|
|
12969
|
+
typeAnnotation: symbol.typeAnnotation ?? null
|
|
12970
|
+
},
|
|
12971
|
+
payload: symbol,
|
|
12972
|
+
denominator: ownsDenominators ? "symbol" : "none"
|
|
12973
|
+
}));
|
|
12974
|
+
}
|
|
12975
|
+
for (const relation of relationsByFile.get(normalizedPath) ?? []) {
|
|
12976
|
+
facts.push(fact2({
|
|
12977
|
+
sourceRef: invocation.authorized_scope.source_ref,
|
|
12978
|
+
moduleRef: invocation.module_ref,
|
|
12979
|
+
normalizedPath,
|
|
12980
|
+
qualifiedItemPath: `relation:${relation.type}:${relation.from}->${relation.to}@${relation.line ?? 0}`,
|
|
12981
|
+
kind: "code-relation",
|
|
12982
|
+
signature: relation,
|
|
12983
|
+
payload: relation,
|
|
12984
|
+
denominator: "none"
|
|
12985
|
+
}));
|
|
12986
|
+
}
|
|
12987
|
+
}
|
|
12988
|
+
return {
|
|
12989
|
+
file_ref: fileRef,
|
|
12990
|
+
source_ref: invocation.authorized_scope.source_ref,
|
|
12991
|
+
module_ref: invocation.module_ref,
|
|
12992
|
+
normalized_path: normalizedPath,
|
|
12993
|
+
role,
|
|
12994
|
+
coverage_tier: coverage.tier,
|
|
12995
|
+
disposition: coverageFile.disposition,
|
|
12996
|
+
facts
|
|
12997
|
+
};
|
|
12998
|
+
});
|
|
12999
|
+
const diagnostics = [
|
|
13000
|
+
...coverage.diagnostics.map((diagnostic) => {
|
|
13001
|
+
const coverageFile = coverageByPath.get(diagnostic.file);
|
|
13002
|
+
const fileRef = coverageFile ? indexerEvidenceAdapterFileRef({
|
|
13003
|
+
source_ref: invocation.authorized_scope.source_ref,
|
|
13004
|
+
module_ref: invocation.module_ref,
|
|
13005
|
+
normalized_path: diagnostic.file
|
|
13006
|
+
}) : undefined;
|
|
13007
|
+
return {
|
|
13008
|
+
code: diagnostic.code,
|
|
13009
|
+
severity: diagnostic.severity,
|
|
13010
|
+
detail_digest: indexerEvidenceAdapterProtocolDigest(diagnosticPayload(diagnostic)),
|
|
13011
|
+
...fileRef ? { fact_ref: fileRef } : {}
|
|
13012
|
+
};
|
|
13013
|
+
}),
|
|
13014
|
+
...generatedDiagnostics
|
|
13015
|
+
];
|
|
13016
|
+
const parserOutputDigest = indexerEvidenceAdapterProtocolDigest(semanticExtractionPayload(extraction));
|
|
13017
|
+
return buildIndexerEvidenceAdapterResult({
|
|
13018
|
+
protocol: "context.indexer.evidence-adapter-result/v1",
|
|
13019
|
+
adapter: invocation.adapter,
|
|
13020
|
+
authorized_scope: invocation.authorized_scope,
|
|
13021
|
+
input_digest: invocation.input_digest,
|
|
13022
|
+
precedence: invocation.precedence,
|
|
13023
|
+
files,
|
|
13024
|
+
diagnostics,
|
|
13025
|
+
toolchain: [{
|
|
13026
|
+
step: "parse-source",
|
|
13027
|
+
package: invocation.adapter.package,
|
|
13028
|
+
export: invocation.adapter.export,
|
|
13029
|
+
version: invocation.adapter.version,
|
|
13030
|
+
digest: invocation.adapter.digest,
|
|
13031
|
+
capabilities: coverage.capabilities,
|
|
13032
|
+
input_digest: invocation.input_digest,
|
|
13033
|
+
output_digest: parserOutputDigest
|
|
13034
|
+
}]
|
|
13035
|
+
});
|
|
13036
|
+
}
|
|
13037
|
+
// ../../node_modules/.bun/eslint-visitor-keys@5.0.1/node_modules/eslint-visitor-keys/lib/visitor-keys.js
|
|
13038
|
+
var KEYS = {
|
|
13039
|
+
ArrayExpression: ["elements"],
|
|
13040
|
+
ArrayPattern: ["elements"],
|
|
13041
|
+
ArrowFunctionExpression: ["params", "body"],
|
|
13042
|
+
AssignmentExpression: ["left", "right"],
|
|
13043
|
+
AssignmentPattern: ["left", "right"],
|
|
13044
|
+
AwaitExpression: ["argument"],
|
|
13045
|
+
BinaryExpression: ["left", "right"],
|
|
13046
|
+
BlockStatement: ["body"],
|
|
13047
|
+
BreakStatement: ["label"],
|
|
13048
|
+
CallExpression: ["callee", "arguments"],
|
|
13049
|
+
CatchClause: ["param", "body"],
|
|
13050
|
+
ChainExpression: ["expression"],
|
|
13051
|
+
ClassBody: ["body"],
|
|
13052
|
+
ClassDeclaration: ["id", "superClass", "body"],
|
|
13053
|
+
ClassExpression: ["id", "superClass", "body"],
|
|
13054
|
+
ConditionalExpression: ["test", "consequent", "alternate"],
|
|
13055
|
+
ContinueStatement: ["label"],
|
|
13056
|
+
DebuggerStatement: [],
|
|
13057
|
+
DoWhileStatement: ["body", "test"],
|
|
13058
|
+
EmptyStatement: [],
|
|
13059
|
+
ExperimentalRestProperty: ["argument"],
|
|
13060
|
+
ExperimentalSpreadProperty: ["argument"],
|
|
13061
|
+
ExportAllDeclaration: ["exported", "source", "attributes"],
|
|
13062
|
+
ExportDefaultDeclaration: ["declaration"],
|
|
13063
|
+
ExportNamedDeclaration: [
|
|
13064
|
+
"declaration",
|
|
13065
|
+
"specifiers",
|
|
13066
|
+
"source",
|
|
13067
|
+
"attributes"
|
|
13068
|
+
],
|
|
13069
|
+
ExportSpecifier: ["local", "exported"],
|
|
13070
|
+
ExpressionStatement: ["expression"],
|
|
13071
|
+
ForInStatement: ["left", "right", "body"],
|
|
13072
|
+
ForOfStatement: ["left", "right", "body"],
|
|
13073
|
+
ForStatement: ["init", "test", "update", "body"],
|
|
13074
|
+
FunctionDeclaration: ["id", "params", "body"],
|
|
13075
|
+
FunctionExpression: ["id", "params", "body"],
|
|
13076
|
+
Identifier: [],
|
|
13077
|
+
IfStatement: ["test", "consequent", "alternate"],
|
|
13078
|
+
ImportAttribute: ["key", "value"],
|
|
13079
|
+
ImportDeclaration: ["specifiers", "source", "attributes"],
|
|
13080
|
+
ImportDefaultSpecifier: ["local"],
|
|
13081
|
+
ImportExpression: ["source", "options"],
|
|
13082
|
+
ImportNamespaceSpecifier: ["local"],
|
|
13083
|
+
ImportSpecifier: ["imported", "local"],
|
|
13084
|
+
JSXAttribute: ["name", "value"],
|
|
13085
|
+
JSXClosingElement: ["name"],
|
|
13086
|
+
JSXClosingFragment: [],
|
|
13087
|
+
JSXElement: ["openingElement", "children", "closingElement"],
|
|
13088
|
+
JSXEmptyExpression: [],
|
|
13089
|
+
JSXExpressionContainer: ["expression"],
|
|
13090
|
+
JSXFragment: ["openingFragment", "children", "closingFragment"],
|
|
13091
|
+
JSXIdentifier: [],
|
|
13092
|
+
JSXMemberExpression: ["object", "property"],
|
|
13093
|
+
JSXNamespacedName: ["namespace", "name"],
|
|
13094
|
+
JSXOpeningElement: ["name", "attributes"],
|
|
13095
|
+
JSXOpeningFragment: [],
|
|
13096
|
+
JSXSpreadAttribute: ["argument"],
|
|
13097
|
+
JSXSpreadChild: ["expression"],
|
|
13098
|
+
JSXText: [],
|
|
13099
|
+
LabeledStatement: ["label", "body"],
|
|
13100
|
+
Literal: [],
|
|
13101
|
+
LogicalExpression: ["left", "right"],
|
|
13102
|
+
MemberExpression: ["object", "property"],
|
|
13103
|
+
MetaProperty: ["meta", "property"],
|
|
13104
|
+
MethodDefinition: ["key", "value"],
|
|
13105
|
+
NewExpression: ["callee", "arguments"],
|
|
13106
|
+
ObjectExpression: ["properties"],
|
|
13107
|
+
ObjectPattern: ["properties"],
|
|
13108
|
+
PrivateIdentifier: [],
|
|
13109
|
+
Program: ["body"],
|
|
13110
|
+
Property: ["key", "value"],
|
|
13111
|
+
PropertyDefinition: ["key", "value"],
|
|
13112
|
+
RestElement: ["argument"],
|
|
13113
|
+
ReturnStatement: ["argument"],
|
|
13114
|
+
SequenceExpression: ["expressions"],
|
|
13115
|
+
SpreadElement: ["argument"],
|
|
13116
|
+
StaticBlock: ["body"],
|
|
13117
|
+
Super: [],
|
|
13118
|
+
SwitchCase: ["test", "consequent"],
|
|
13119
|
+
SwitchStatement: ["discriminant", "cases"],
|
|
13120
|
+
TaggedTemplateExpression: ["tag", "quasi"],
|
|
13121
|
+
TemplateElement: [],
|
|
13122
|
+
TemplateLiteral: ["quasis", "expressions"],
|
|
13123
|
+
ThisExpression: [],
|
|
13124
|
+
ThrowStatement: ["argument"],
|
|
13125
|
+
TryStatement: ["block", "handler", "finalizer"],
|
|
13126
|
+
UnaryExpression: ["argument"],
|
|
13127
|
+
UpdateExpression: ["argument"],
|
|
13128
|
+
VariableDeclaration: ["declarations"],
|
|
13129
|
+
VariableDeclarator: ["id", "init"],
|
|
13130
|
+
WhileStatement: ["test", "body"],
|
|
13131
|
+
WithStatement: ["object", "body"],
|
|
13132
|
+
YieldExpression: ["argument"]
|
|
13133
|
+
};
|
|
13134
|
+
var NODE_TYPES = Object.keys(KEYS);
|
|
13135
|
+
for (const type of NODE_TYPES) {
|
|
13136
|
+
Object.freeze(KEYS[type]);
|
|
13137
|
+
}
|
|
13138
|
+
Object.freeze(KEYS);
|
|
13139
|
+
var visitor_keys_default = KEYS;
|
|
13140
|
+
|
|
13141
|
+
// ../../node_modules/.bun/eslint-visitor-keys@5.0.1/node_modules/eslint-visitor-keys/lib/index.js
|
|
13142
|
+
var KEY_BLACKLIST = new Set([
|
|
13143
|
+
"parent",
|
|
13144
|
+
"leadingComments",
|
|
13145
|
+
"trailingComments"
|
|
13146
|
+
]);
|
|
13147
|
+
function unionWith(additionalKeys) {
|
|
13148
|
+
const retv = Object.assign({}, visitor_keys_default);
|
|
13149
|
+
for (const type of Object.keys(additionalKeys)) {
|
|
13150
|
+
if (Object.hasOwn(retv, type)) {
|
|
13151
|
+
const keys = new Set(additionalKeys[type]);
|
|
13152
|
+
for (const key of retv[type]) {
|
|
13153
|
+
keys.add(key);
|
|
13154
|
+
}
|
|
13155
|
+
retv[type] = Object.freeze(Array.from(keys));
|
|
13156
|
+
} else {
|
|
13157
|
+
retv[type] = Object.freeze(Array.from(additionalKeys[type]));
|
|
13158
|
+
}
|
|
13159
|
+
}
|
|
13160
|
+
return Object.freeze(retv);
|
|
13161
|
+
}
|
|
13162
|
+
|
|
13163
|
+
// ../../node_modules/.bun/toml-eslint-parser@1.0.3/node_modules/toml-eslint-parser/lib/index.mjs
|
|
13164
|
+
function last(arr) {
|
|
13165
|
+
return arr[arr.length - 1] ?? null;
|
|
13166
|
+
}
|
|
13167
|
+
var TOMLVerImpl = class {
|
|
13168
|
+
constructor(major, minor) {
|
|
13169
|
+
this.major = major;
|
|
13170
|
+
this.minor = minor;
|
|
13171
|
+
}
|
|
13172
|
+
lt(major, minor) {
|
|
13173
|
+
return this.major < major || this.major === major && this.minor < minor;
|
|
13174
|
+
}
|
|
13175
|
+
gte(major, minor) {
|
|
13176
|
+
return this.major > major || this.major === major && this.minor >= minor;
|
|
13177
|
+
}
|
|
13178
|
+
};
|
|
13179
|
+
var TOML_VERSION_1_0 = new TOMLVerImpl(1, 0);
|
|
13180
|
+
var TOML_VERSION_1_1 = new TOMLVerImpl(1, 1);
|
|
13181
|
+
var CodePoint = {
|
|
13182
|
+
EOF: -1,
|
|
13183
|
+
NULL: 0,
|
|
13184
|
+
SOH: 1,
|
|
13185
|
+
BACKSPACE: 8,
|
|
13186
|
+
TABULATION: 9,
|
|
13187
|
+
LINE_FEED: 10,
|
|
13188
|
+
FORM_FEED: 12,
|
|
13189
|
+
CARRIAGE_RETURN: 13,
|
|
13190
|
+
ESCAPE: 27,
|
|
13191
|
+
SO: 14,
|
|
13192
|
+
US: 31,
|
|
13193
|
+
SPACE: 32,
|
|
13194
|
+
QUOTATION_MARK: 34,
|
|
13195
|
+
HASH: 35,
|
|
13196
|
+
SINGLE_QUOTE: 39,
|
|
13197
|
+
PLUS_SIGN: 43,
|
|
13198
|
+
COMMA: 44,
|
|
13199
|
+
DASH: 45,
|
|
13200
|
+
DOT: 46,
|
|
13201
|
+
DIGIT_0: 48,
|
|
13202
|
+
DIGIT_1: 49,
|
|
13203
|
+
DIGIT_2: 50,
|
|
13204
|
+
DIGIT_3: 51,
|
|
13205
|
+
DIGIT_7: 55,
|
|
13206
|
+
DIGIT_9: 57,
|
|
13207
|
+
COLON: 58,
|
|
13208
|
+
EQUALS_SIGN: 61,
|
|
13209
|
+
LATIN_CAPITAL_A: 65,
|
|
13210
|
+
LATIN_CAPITAL_E: 69,
|
|
13211
|
+
LATIN_CAPITAL_F: 70,
|
|
13212
|
+
LATIN_CAPITAL_T: 84,
|
|
13213
|
+
LATIN_CAPITAL_U: 85,
|
|
13214
|
+
LATIN_CAPITAL_Z: 90,
|
|
13215
|
+
LEFT_BRACKET: 91,
|
|
13216
|
+
BACKSLASH: 92,
|
|
13217
|
+
RIGHT_BRACKET: 93,
|
|
13218
|
+
UNDERSCORE: 95,
|
|
13219
|
+
LATIN_SMALL_A: 97,
|
|
13220
|
+
LATIN_SMALL_B: 98,
|
|
13221
|
+
LATIN_SMALL_E: 101,
|
|
13222
|
+
LATIN_SMALL_F: 102,
|
|
13223
|
+
LATIN_SMALL_I: 105,
|
|
13224
|
+
LATIN_SMALL_L: 108,
|
|
13225
|
+
LATIN_SMALL_N: 110,
|
|
13226
|
+
LATIN_SMALL_O: 111,
|
|
13227
|
+
LATIN_SMALL_R: 114,
|
|
13228
|
+
LATIN_SMALL_S: 115,
|
|
13229
|
+
LATIN_SMALL_T: 116,
|
|
13230
|
+
LATIN_SMALL_U: 117,
|
|
13231
|
+
LATIN_SMALL_X: 120,
|
|
13232
|
+
LATIN_SMALL_Z: 122,
|
|
13233
|
+
LEFT_BRACE: 123,
|
|
13234
|
+
RIGHT_BRACE: 125,
|
|
13235
|
+
TILDE: 126,
|
|
13236
|
+
DELETE: 127,
|
|
13237
|
+
PAD: 128,
|
|
13238
|
+
SUPERSCRIPT_TWO: 178,
|
|
13239
|
+
SUPERSCRIPT_THREE: 179,
|
|
13240
|
+
SUPERSCRIPT_ONE: 185,
|
|
13241
|
+
VULGAR_FRACTION_ONE_QUARTER: 188,
|
|
13242
|
+
VULGAR_FRACTION_THREE_QUARTERS: 190,
|
|
13243
|
+
LATIN_CAPITAL_LETTER_A_WITH_GRAVE: 192,
|
|
13244
|
+
LATIN_CAPITAL_LETTER_O_WITH_DIAERESIS: 214,
|
|
13245
|
+
LATIN_CAPITAL_LETTER_O_WITH_STROKE: 216,
|
|
13246
|
+
LATIN_SMALL_LETTER_O_WITH_DIAERESIS: 246,
|
|
13247
|
+
LATIN_SMALL_LETTER_O_WITH_STROKE: 248,
|
|
13248
|
+
GREEK_SMALL_REVERSED_DOTTED_LUNATE_SIGMA_SYMBOL: 891,
|
|
13249
|
+
GREEK_CAPITAL_LETTER_YOT: 895,
|
|
13250
|
+
CP_1FFF: 8191,
|
|
13251
|
+
ZERO_WIDTH_NON_JOINER: 8204,
|
|
13252
|
+
ZERO_WIDTH_JOINER: 8205,
|
|
13253
|
+
UNDERTIE: 8255,
|
|
13254
|
+
CHARACTER_TIE: 8256,
|
|
13255
|
+
SUPERSCRIPT_ZERO: 8304,
|
|
13256
|
+
CP_218F: 8591,
|
|
13257
|
+
CIRCLED_DIGIT_ONE: 9312,
|
|
13258
|
+
NEGATIVE_CIRCLED_DIGIT_ZERO: 9471,
|
|
13259
|
+
GLAGOLITIC_CAPITAL_LETTER_AZU: 11264,
|
|
13260
|
+
CP_2FEF: 12271,
|
|
13261
|
+
IDEOGRAPHIC_COMMA: 12289,
|
|
13262
|
+
CP_D7FF: 55295,
|
|
13263
|
+
CP_E000: 57344,
|
|
13264
|
+
CJK_COMPATIBILITY_IDEOGRAPH_F900: 63744,
|
|
13265
|
+
ARABIC_LIGATURE_SALAAMUHU_ALAYNAA: 64975,
|
|
13266
|
+
ARABIC_LIGATURE_SALLA_USED_AS_KORANIC_STOP_SIGN_ISOLATED_FORM: 65008,
|
|
13267
|
+
REPLACEMENT_CHARACTER: 65533,
|
|
13268
|
+
LINEAR_B_SYLLABLE_B008_A: 65536,
|
|
13269
|
+
CP_EFFFF: 983039,
|
|
13270
|
+
CP_10FFFF: 1114111
|
|
13271
|
+
};
|
|
13272
|
+
var ESCAPES_1_0 = {
|
|
13273
|
+
[CodePoint.QUOTATION_MARK]: CodePoint.QUOTATION_MARK,
|
|
13274
|
+
[CodePoint.BACKSLASH]: CodePoint.BACKSLASH,
|
|
13275
|
+
[CodePoint.LATIN_SMALL_B]: CodePoint.BACKSPACE,
|
|
13276
|
+
[CodePoint.LATIN_SMALL_F]: CodePoint.FORM_FEED,
|
|
13277
|
+
[CodePoint.LATIN_SMALL_N]: CodePoint.LINE_FEED,
|
|
13278
|
+
[CodePoint.LATIN_SMALL_R]: CodePoint.CARRIAGE_RETURN,
|
|
13279
|
+
[CodePoint.LATIN_SMALL_T]: CodePoint.TABULATION
|
|
13280
|
+
};
|
|
13281
|
+
var ESCAPES_LATEST = {
|
|
13282
|
+
...ESCAPES_1_0,
|
|
13283
|
+
[CodePoint.LATIN_SMALL_E]: CodePoint.ESCAPE
|
|
13284
|
+
};
|
|
13285
|
+
var VALUE_KIND_VALUE = Symbol("VALUE_KIND_VALUE");
|
|
13286
|
+
var VALUE_KIND_INTERMEDIATE = Symbol("VALUE_KIND_INTERMEDIATE");
|
|
13287
|
+
var tomlKeys = {
|
|
13288
|
+
Program: ["body"],
|
|
13289
|
+
TOMLTopLevelTable: ["body"],
|
|
13290
|
+
TOMLTable: ["key", "body"],
|
|
13291
|
+
TOMLKeyValue: ["key", "value"],
|
|
13292
|
+
TOMLKey: ["keys"],
|
|
13293
|
+
TOMLArray: ["elements"],
|
|
13294
|
+
TOMLInlineTable: ["body"],
|
|
13295
|
+
TOMLBare: [],
|
|
13296
|
+
TOMLQuoted: [],
|
|
13297
|
+
TOMLValue: []
|
|
13298
|
+
};
|
|
13299
|
+
var KEYS2 = unionWith(tomlKeys);
|
|
13300
|
+
var getStaticTOMLValue = generateConvertTOMLValue((node2) => node2.value);
|
|
13301
|
+
function generateConvertTOMLValue(convertValue) {
|
|
13302
|
+
function resolveValue(node2, baseTable) {
|
|
13303
|
+
return resolver[node2.type](node2, baseTable);
|
|
13304
|
+
}
|
|
13305
|
+
const resolver = {
|
|
13306
|
+
Program(node2, baseTable = {}) {
|
|
13307
|
+
return resolveValue(node2.body[0], baseTable);
|
|
13308
|
+
},
|
|
13309
|
+
TOMLTopLevelTable(node2, baseTable = {}) {
|
|
13310
|
+
for (const body of node2.body)
|
|
13311
|
+
resolveValue(body, baseTable);
|
|
13312
|
+
return baseTable;
|
|
13313
|
+
},
|
|
13314
|
+
TOMLKeyValue(node2, baseTable = {}) {
|
|
13315
|
+
const value = resolveValue(node2.value);
|
|
13316
|
+
set(baseTable, resolveValue(node2.key), value);
|
|
13317
|
+
return baseTable;
|
|
13318
|
+
},
|
|
13319
|
+
TOMLTable(node2, baseTable = {}) {
|
|
13320
|
+
const table = getTable(baseTable, resolveValue(node2.key), node2.kind === "array");
|
|
13321
|
+
for (const body of node2.body)
|
|
13322
|
+
resolveValue(body, table);
|
|
13323
|
+
return baseTable;
|
|
13324
|
+
},
|
|
13325
|
+
TOMLArray(node2) {
|
|
13326
|
+
return node2.elements.map((e) => resolveValue(e));
|
|
13327
|
+
},
|
|
13328
|
+
TOMLInlineTable(node2) {
|
|
13329
|
+
const table = {};
|
|
13330
|
+
for (const body of node2.body)
|
|
13331
|
+
resolveValue(body, table);
|
|
13332
|
+
return table;
|
|
13333
|
+
},
|
|
13334
|
+
TOMLKey(node2) {
|
|
13335
|
+
return node2.keys.map((key) => resolveValue(key));
|
|
13336
|
+
},
|
|
13337
|
+
TOMLBare(node2) {
|
|
13338
|
+
return node2.name;
|
|
13339
|
+
},
|
|
13340
|
+
TOMLQuoted(node2) {
|
|
13341
|
+
return node2.value;
|
|
13342
|
+
},
|
|
13343
|
+
TOMLValue(node2) {
|
|
13344
|
+
return convertValue(node2);
|
|
13345
|
+
}
|
|
13346
|
+
};
|
|
13347
|
+
return (node2) => resolveValue(node2);
|
|
13348
|
+
}
|
|
13349
|
+
function getTable(baseTable, keys, array) {
|
|
13350
|
+
let target = baseTable;
|
|
13351
|
+
for (let index = 0;index < keys.length - 1; index++) {
|
|
13352
|
+
const key = keys[index];
|
|
13353
|
+
target = getNextTargetFromKey(target, key);
|
|
13354
|
+
}
|
|
13355
|
+
const lastKey = last(keys);
|
|
13356
|
+
const lastTarget = target[lastKey];
|
|
13357
|
+
if (lastTarget == null) {
|
|
13358
|
+
const tableValue$1 = {};
|
|
13359
|
+
target[lastKey] = array ? [tableValue$1] : tableValue$1;
|
|
13360
|
+
return tableValue$1;
|
|
13361
|
+
}
|
|
13362
|
+
if (isValue(lastTarget)) {
|
|
13363
|
+
const tableValue$1 = {};
|
|
13364
|
+
target[lastKey] = array ? [tableValue$1] : tableValue$1;
|
|
13365
|
+
return tableValue$1;
|
|
13366
|
+
}
|
|
13367
|
+
if (!array) {
|
|
13368
|
+
if (Array.isArray(lastTarget)) {
|
|
13369
|
+
const tableValue$1 = {};
|
|
13370
|
+
target[lastKey] = tableValue$1;
|
|
13371
|
+
return tableValue$1;
|
|
13372
|
+
}
|
|
13373
|
+
return lastTarget;
|
|
13374
|
+
}
|
|
13375
|
+
if (Array.isArray(lastTarget)) {
|
|
13376
|
+
const tableValue$1 = {};
|
|
13377
|
+
lastTarget.push(tableValue$1);
|
|
13378
|
+
return tableValue$1;
|
|
13379
|
+
}
|
|
13380
|
+
const tableValue = {};
|
|
13381
|
+
target[lastKey] = [tableValue];
|
|
13382
|
+
return tableValue;
|
|
13383
|
+
function getNextTargetFromKey(currTarget, key) {
|
|
13384
|
+
const nextTarget = currTarget[key];
|
|
13385
|
+
if (nextTarget == null) {
|
|
13386
|
+
const val = {};
|
|
13387
|
+
currTarget[key] = val;
|
|
13388
|
+
return val;
|
|
13389
|
+
}
|
|
13390
|
+
if (isValue(nextTarget)) {
|
|
13391
|
+
const val = {};
|
|
13392
|
+
currTarget[key] = val;
|
|
13393
|
+
return val;
|
|
13394
|
+
}
|
|
13395
|
+
let resultTarget = nextTarget;
|
|
13396
|
+
while (Array.isArray(resultTarget)) {
|
|
13397
|
+
const lastIndex = resultTarget.length - 1;
|
|
13398
|
+
const nextElement = resultTarget[lastIndex];
|
|
13399
|
+
if (isValue(nextElement)) {
|
|
13400
|
+
const val = {};
|
|
13401
|
+
resultTarget[lastIndex] = val;
|
|
13402
|
+
return val;
|
|
13403
|
+
}
|
|
13404
|
+
resultTarget = nextElement;
|
|
13405
|
+
}
|
|
13406
|
+
return resultTarget;
|
|
13407
|
+
}
|
|
13408
|
+
}
|
|
13409
|
+
function set(baseTable, keys, value) {
|
|
13410
|
+
let target = baseTable;
|
|
13411
|
+
for (let index = 0;index < keys.length - 1; index++) {
|
|
13412
|
+
const key = keys[index];
|
|
13413
|
+
const nextTarget = target[key];
|
|
13414
|
+
if (nextTarget == null) {
|
|
13415
|
+
const val = {};
|
|
13416
|
+
target[key] = val;
|
|
13417
|
+
target = val;
|
|
13418
|
+
} else if (isValue(nextTarget) || Array.isArray(nextTarget)) {
|
|
13419
|
+
const val = {};
|
|
13420
|
+
target[key] = val;
|
|
13421
|
+
target = val;
|
|
13422
|
+
} else
|
|
13423
|
+
target = nextTarget;
|
|
13424
|
+
}
|
|
13425
|
+
target[last(keys)] = value;
|
|
13426
|
+
}
|
|
13427
|
+
function isValue(value) {
|
|
13428
|
+
return typeof value !== "object" || value instanceof Date;
|
|
13429
|
+
}
|
|
13430
|
+
|
|
13431
|
+
// ../extract/src/configEvidenceParser.ts
|
|
13432
|
+
var import_yaml2 = __toESM(require_dist(), 1);
|
|
13433
|
+
// ../extract/src/parser.ts
|
|
13434
|
+
import * as WebTreeSitter from "web-tree-sitter";
|
|
13435
|
+
var treeSitterRuntime = WebTreeSitter;
|
|
13436
|
+
var Parser2 = treeSitterRuntime.default ?? treeSitterRuntime.Parser;
|
|
13437
|
+
if (!Parser2) {
|
|
13438
|
+
throw new TypeError("web-tree-sitter runtime does not expose Parser");
|
|
13439
|
+
}
|
|
13440
|
+
var PARSER_RESET_THRESHOLD = 16 * 1024 * 1024;
|
|
13441
|
+
// src/evidenceAdapter.ts
|
|
13442
|
+
function goExtractionToEvidenceAdapterResult(extraction, invocation) {
|
|
13443
|
+
if (extraction.meta.pluginId !== "c4a-extract-go") {
|
|
13444
|
+
throw new TypeError("Go evidence adapter requires c4a-extract-go output");
|
|
13445
|
+
}
|
|
13446
|
+
return extractionResultToEvidenceAdapterResult(extraction, invocation);
|
|
13447
|
+
}
|
|
12136
13448
|
export {
|
|
12137
13449
|
indexGoSource,
|
|
12138
13450
|
indexGoRepository,
|
|
13451
|
+
goExtractionToEvidenceAdapterResult,
|
|
12139
13452
|
GoPlugin
|
|
12140
13453
|
};
|