@repometry/core 0.6.0 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@repometry/core",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "The Repometry plugin API and inspection engine",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -157,7 +157,8 @@
157
157
  "source",
158
158
  "maintainability",
159
159
  "coverage",
160
- "security"
160
+ "security",
161
+ "legal"
161
162
  ]
162
163
  },
163
164
  "checks": {
@@ -226,6 +227,10 @@
226
227
  }
227
228
  }
228
229
  },
230
+ "nestedBlockComments": {
231
+ "type": "boolean",
232
+ "description": "Each repeated opening marker of the active block-comment pair increases the nesting depth."
233
+ },
229
234
  "strings": {
230
235
  "type": "array",
231
236
  "items": {
@@ -238,6 +243,14 @@
238
243
  "quote": {
239
244
  "$ref": "#/$defs/syntax/$defs/marker"
240
245
  },
246
+ "end": {
247
+ "$ref": "#/$defs/syntax/$defs/marker",
248
+ "description": "Closing marker. Defaults to the opening quote."
249
+ },
250
+ "doubleEnd": {
251
+ "type": "boolean",
252
+ "description": "Treat two consecutive closing markers as an escaped closing marker."
253
+ },
241
254
  "multiline": {
242
255
  "type": "boolean"
243
256
  },
@@ -30,7 +30,7 @@ function writeFinding(value, id, dimension, encoding) {
30
30
  const { plugin, check, ...fields } = value;
31
31
  if (id !== undefined && plugin !== undefined && plugin !== id)
32
32
  throw new Error('A finding may only name its reporting plugin ' + id);
33
- if (dimension !== undefined && dimension !== category.maintainability && dimension !== category.security) {
33
+ if (dimension !== undefined && dimension !== category.maintainability && dimension !== category.security && dimension !== category.legal) {
34
34
  throw new Error('Plugins in ' + dimension + ' do not produce findings');
35
35
  }
36
36
  if (encoding) {
@@ -49,8 +49,8 @@ export function readFindings(value) {
49
49
  return { ...value, findings: value.findings.map(({ tool, rule, category, ...entry }) => ({ ...entry, plugin: tool, check: rule })) };
50
50
  }
51
51
  export function findingCategory(dimension, chargesEffort) {
52
- if (dimension === category.security)
53
- return 'security';
52
+ if (dimension === category.security || dimension === category.legal)
53
+ return dimension;
54
54
  return chargesEffort ? 'structure' : 'lint';
55
55
  }
56
56
  //# sourceMappingURL=author-contracts.js.map
@@ -3,7 +3,7 @@ import { findingResult } from '../model/finding.js';
3
3
  import { definitions, measurements } from '../model/measurement.js';
4
4
  import { structureMeasures } from '../model/code-structure.js';
5
5
  import { isLanguageDisplay, isLanguageSyntax } from '../model/language.js';
6
- const kinds = new Set(['language', 'analysis', 'coverage', 'security', 'import', 'source']);
6
+ const kinds = new Set(['language', 'analysis', 'coverage', 'security', 'legal', 'import', 'source']);
7
7
  const persistence = new Set(['report', 'cache', 'transient']);
8
8
  const units = new Set(['count', 'ratio', 'minutes']);
9
9
  const scopes = new Set(['repository', 'file', 'function']);
@@ -15,11 +15,11 @@ export function bundledPlugin(manifest, encoding) {
15
15
  return { ...plugin, ...(rules === undefined ? {} : { rules }), ...manifestOperations(manifest, manifest.create(), encoding) };
16
16
  }
17
17
  export function pluginCategory(plugin) {
18
- const categories = [category.language, category.source, category.security, category.coverage];
18
+ const categories = [category.language, category.source, category.security, category.coverage, category.legal];
19
19
  return categories.find(value => plugin.kinds.includes(value)) ?? category.maintainability;
20
20
  }
21
21
  const kindsByCategory = {
22
- language: 'language', source: 'source', maintainability: 'analysis', coverage: 'coverage', security: 'security',
22
+ language: 'language', source: 'source', maintainability: 'analysis', coverage: 'coverage', security: 'security', legal: 'legal',
23
23
  };
24
24
  export function manifestPlugin({ id, category, languages, optionsSchema, tools, checks }, version) {
25
25
  return { id, version, api: pluginApi, kinds: [kindsByCategory[category]], config: optionsSchema, tools,
@@ -40,7 +40,7 @@ export interface RuleDescriptor {
40
40
  readonly per?: readonly [singular: string, plural: string];
41
41
  }
42
42
  export type PluginConfigSchema = boolean | Readonly<Record<string, unknown>>;
43
- export type PluginKind = 'language' | 'analysis' | 'coverage' | 'security' | 'import' | 'source';
43
+ export type PluginKind = 'language' | 'analysis' | 'coverage' | 'security' | 'legal' | 'import' | 'source';
44
44
  export interface FileClaims {
45
45
  readonly extensions?: readonly string[];
46
46
  readonly globs?: readonly string[];
@@ -4,3 +4,5 @@ export declare const cppSyntax: LanguageSyntax;
4
4
  export declare const jsonSyntax: LanguageSyntax;
5
5
  export declare const cssSyntax: LanguageSyntax;
6
6
  export declare const dockerfileSyntax: LanguageSyntax;
7
+ export declare const goModuleSyntax: LanguageSyntax;
8
+ export declare const tomlSyntax: LanguageSyntax;
@@ -18,6 +18,10 @@ export const cSyntax = {
18
18
  // WG21 N4950 §5.11. Delimited raw strings can contain unbalanced block markers.
19
19
  export const cppSyntax = {
20
20
  ...cFamily,
21
+ strings: [
22
+ ...['R', 'LR', 'u8R', 'uR', 'UR'].map(prefix => ({ quote: prefix + '"(', end: ')"', raw: true, multiline: true })),
23
+ ...cFamily.strings,
24
+ ],
21
25
  keywords: [
22
26
  'alignas', 'alignof', 'and', 'and_eq', 'asm', 'auto', 'bitand', 'bitor', 'bool', 'break', 'case', 'catch',
23
27
  'char', 'char8_t', 'char16_t', 'char32_t', 'class', 'compl', 'concept', 'const', 'consteval', 'constexpr',
@@ -47,4 +51,16 @@ export const dockerfileSyntax = {
47
51
  'ONBUILD', 'RUN', 'SHELL', 'STOPSIGNAL', 'USER', 'VOLUME', 'WORKDIR', 'AS',
48
52
  ],
49
53
  };
54
+ // Go Modules Reference, lexical elements. Directive words can also occur in module paths.
55
+ export const goModuleSyntax = {
56
+ lineComments: ['//'],
57
+ strings: [{ quote: '"' }, { quote: '`', raw: true }],
58
+ };
59
+ export const tomlSyntax = {
60
+ lineComments: ['#'],
61
+ strings: [
62
+ { quote: '"""', multiline: true }, { quote: "'''", multiline: true, raw: true },
63
+ { quote: '"' }, { quote: "'", raw: true },
64
+ ],
65
+ };
50
66
  //# sourceMappingURL=file-type-syntax.js.map
@@ -1,11 +1,12 @@
1
1
  import { posix } from 'node:path';
2
- import { cppSyntax, cssSyntax, cSyntax, dockerfileSyntax, jsonSyntax } from './file-type-syntax.js';
2
+ import { cppSyntax, cssSyntax, cSyntax, dockerfileSyntax, goModuleSyntax, jsonSyntax, tomlSyntax } from './file-type-syntax.js';
3
3
  export const javascriptType = { id: 'javascript', label: 'JavaScript', color: '#f1e05a', extensions: ['.js', '.mjs', '.cjs', '.jsx'] };
4
4
  export const typescriptType = { id: 'typescript', label: 'TypeScript', color: '#3178c6', extensions: ['.ts', '.mts', '.cts', '.tsx'] };
5
5
  export const fileTypes = [
6
6
  javascriptType, typescriptType,
7
7
  { id: 'markdown', label: 'Markdown', color: '#768390', extensions: ['.md', '.mdx', '.markdown'] },
8
8
  { id: 'yaml', label: 'YAML', color: '#c47d84', extensions: ['.yaml', '.yml'] },
9
+ { id: 'toml', label: 'TOML', extensions: ['.toml'], syntax: tomlSyntax },
9
10
  { id: 'json', label: 'JSON', color: '#9b86b5', extensions: ['.json'], syntax: jsonSyntax },
10
11
  { id: 'css', label: 'CSS', color: '#663399', extensions: ['.css'], syntax: cssSyntax },
11
12
  { id: 'scss', label: 'SCSS', color: '#c6538c', extensions: ['.scss'] },
@@ -17,7 +18,7 @@ export const fileTypes = [
17
18
  extensions: ['.dockerfile'], syntax: dockerfileSyntax },
18
19
  { id: 'python', label: 'Python', color: '#3572a5', extensions: ['.py'] },
19
20
  { id: 'go', label: 'Go', color: '#00add8', extensions: ['.go'] },
20
- { id: 'go-module', label: 'Go module', color: '#008ba8', exactNames: ['go.mod'] },
21
+ { id: 'go-module', label: 'Go module', color: '#008ba8', exactNames: ['go.mod'], syntax: goModuleSyntax },
21
22
  { id: 'go-checksums', label: 'Go checksums', color: '#487b91', exactNames: ['go.sum'] },
22
23
  { id: 'rust', label: 'Rust', color: '#dea584', extensions: ['.rs'] },
23
24
  { id: 'java', label: 'Java', color: '#b07219', extensions: ['.java'] },
@@ -4,7 +4,7 @@ import { exclusionMatcher, normalizeExclusions } from '../profile/exclusions.js'
4
4
  const fields = new Set(['tool', 'rule', 'path', 'reason', 'category']);
5
5
  const inspectionCategory = {
6
6
  structure: inspection.maintainability, duplication: inspection.maintainability, lint: inspection.maintainability,
7
- security: 'security', dependency: 'security', secret: 'security', infrastructure: 'security',
7
+ security: 'security', dependency: 'security', secret: 'security', infrastructure: 'security', legal: inspection.legal,
8
8
  };
9
9
  export function normalizeFindingIgnore(value) {
10
10
  if (!Array.isArray(value))
@@ -14,7 +14,7 @@ export function normalizeFindingIgnore(value) {
14
14
  throw new Error('Invalid recorded ignore entry');
15
15
  }
16
16
  const { tool, rule, path, reason, category } = item;
17
- if (category !== undefined && ![inspection.maintainability, inspection.coverage, inspection.security].includes(category)) {
17
+ if (category !== undefined && ![inspection.maintainability, inspection.coverage, inspection.security, inspection.legal].includes(category)) {
18
18
  throw new Error('Invalid recorded ignore category');
19
19
  }
20
20
  if (tool === undefined && rule === undefined && path === undefined && category === undefined) {
@@ -1,6 +1,6 @@
1
1
  import type { DataContract } from '../engine/plugin.js';
2
2
  import type { Measurement } from './measurement.js';
3
- export declare const findingCategories: readonly ['structure', 'duplication', 'lint', 'security', 'dependency', 'secret', 'infrastructure'];
3
+ export declare const findingCategories: readonly ['structure', 'duplication', 'lint', 'security', 'dependency', 'secret', 'infrastructure', 'legal'];
4
4
  export declare const findingLevels: readonly ['low', 'medium', 'high', 'unknown'];
5
5
  export interface FindingLocation {
6
6
  readonly path: string;
@@ -30,5 +30,9 @@ export declare function isFinding(value: unknown): value is Finding;
30
30
  export interface FindingResult {
31
31
  readonly measurements: readonly Measurement[];
32
32
  readonly findings: readonly Finding[];
33
+ readonly ignored?: readonly {
34
+ readonly index: number;
35
+ readonly reason: string;
36
+ }[];
33
37
  }
34
38
  export declare const findingResult: DataContract<FindingResult>;
@@ -1,6 +1,6 @@
1
1
  import { isRecord } from './plugin-data.js';
2
2
  import { measurements } from './measurement.js';
3
- export const findingCategories = ['structure', 'duplication', 'lint', 'security', 'dependency', 'secret', 'infrastructure'];
3
+ export const findingCategories = ['structure', 'duplication', 'lint', 'security', 'dependency', 'secret', 'infrastructure', 'legal'];
4
4
  export const findingLevels = ['low', 'medium', 'high', 'unknown'];
5
5
  export function isSensitiveFinding(category) {
6
6
  return category === 'security' || category === 'dependency' || category === 'secret' || category === 'infrastructure';
@@ -40,6 +40,13 @@ function measure(value) {
40
40
  export const findingResult = {
41
41
  id: 'repometry.findings-and-measurements/v1',
42
42
  accepts: (value) => isRecord(value) && measurements.accepts(value.measurements)
43
- && Array.isArray(value.findings) && value.findings.every(isFinding),
43
+ && Array.isArray(value.findings) && value.findings.every(isFinding) && acceptsExceptions(value.ignored, value.findings.length),
44
44
  };
45
+ function acceptsExceptions(value, findings) {
46
+ if (value === undefined)
47
+ return true;
48
+ return Array.isArray(value) && value.every(item => isRecord(item) && typeof item.index === 'number'
49
+ && count(item.index, 0) && item.index < findings && typeof item.reason === 'string' && item.reason.trim().length > 0)
50
+ && new Set(value.map(item => item.index)).size === value.length;
51
+ }
45
52
  //# sourceMappingURL=finding.js.map
@@ -1,6 +1,6 @@
1
1
  import type { category } from './inspection-category.js';
2
2
  import type { Finding } from './finding.js';
3
- export type InspectionIgnoreCategory = typeof category.maintainability | typeof category.security | typeof category.coverage;
3
+ export type InspectionIgnoreCategory = typeof category.maintainability | typeof category.security | typeof category.coverage | typeof category.legal;
4
4
  export interface FindingIgnoreRule {
5
5
  readonly category?: InspectionIgnoreCategory;
6
6
  readonly plugin?: string;
@@ -16,7 +16,12 @@ export interface RecordedFindingIgnore {
16
16
  readonly path?: string | readonly string[];
17
17
  readonly reason?: string;
18
18
  }
19
- export interface IgnoredFinding {
19
+ export type IgnoredFinding = {
20
20
  readonly finding: Finding;
21
+ } & ({
21
22
  readonly matchedRule: number;
22
- }
23
+ readonly reason?: never;
24
+ } | {
25
+ readonly reason: string;
26
+ readonly matchedRule?: never;
27
+ });
@@ -4,5 +4,6 @@ export declare const category: {
4
4
  readonly maintainability: 'maintainability';
5
5
  readonly coverage: 'coverage';
6
6
  readonly security: 'security';
7
+ readonly legal: 'legal';
7
8
  };
8
9
  export type PluginCategory = typeof category[keyof typeof category];
@@ -4,5 +4,6 @@ export const category = {
4
4
  maintainability: 'maintainability',
5
5
  coverage: 'coverage',
6
6
  security: 'security',
7
+ legal: 'legal',
7
8
  };
8
9
  //# sourceMappingURL=inspection-category.js.map
@@ -16,14 +16,17 @@ export interface LanguageLookup {
16
16
  export interface LanguageSyntax {
17
17
  /** Markers that start a comment running to the end of the line, such as `//` or `#`. */
18
18
  readonly lineComments?: readonly string[];
19
- /** Start and end markers of comments that may span lines, such as slash-star and star-slash. They do not nest. */
19
+ /** Start and end markers of comments that may span lines, such as slash-star and star-slash. */
20
20
  readonly blockComments?: readonly (readonly [start: string, end: string])[];
21
- /**
22
- * String forms. A string ends at the same quote that opened it. A backslash escapes the next character unless the form
23
- * is raw. A form that is not multi-line ends at the end of the line.
24
- */
21
+ /** Repeated opening markers of an active block-comment pair increase its depth. */
22
+ readonly nestedBlockComments?: boolean;
23
+ /** A single-line string ends at the line boundary. Backslashes escape the next character unless `raw` is set. */
25
24
  readonly strings?: readonly {
26
25
  readonly quote: string;
26
+ /** The closing marker, which defaults to `quote`. */
27
+ readonly end?: string;
28
+ /** Treat two consecutive closing markers as an escaped closing marker. */
29
+ readonly doubleEnd?: boolean;
27
30
  readonly multiline?: boolean;
28
31
  readonly raw?: boolean;
29
32
  }[];
@@ -8,6 +8,7 @@ const syntaxChecks = {
8
8
  lineComments: value => entries(value, marker),
9
9
  blockComments: value => entries(value, pair => Array.isArray(pair) && pair.length === 2 && marker(pair[0]) && marker(pair[1])),
10
10
  strings: value => entries(value, stringForm),
11
+ nestedBlockComments: value => typeof value === 'boolean',
11
12
  stringPrefixes: value => entries(value, word),
12
13
  keywords: value => entries(value, word, 512),
13
14
  regexAfter: value => entries(value, word),
@@ -26,6 +27,7 @@ function word(value) {
26
27
  return typeof value === 'string' && /^[A-Za-z_$][\w$]*$/.test(value);
27
28
  }
28
29
  function stringForm(value) {
29
- return isRecord(value) && marker(value.quote) && Object.entries(value).every(([key, item]) => key === 'quote' || ((key === 'multiline' || key === 'raw') && typeof item === 'boolean'));
30
+ return isRecord(value) && marker(value.quote) && Object.entries(value).every(([key, item]) => key === 'quote' || (key === 'end' ? marker(item)
31
+ : (key === 'multiline' || key === 'raw' || key === 'doubleEnd') && typeof item === 'boolean'));
30
32
  }
31
33
  //# sourceMappingURL=language.js.map
@@ -0,0 +1,42 @@
1
+ import type { DataContract } from '../engine/plugin.js';
2
+ import type { SourceFile } from './source.js';
3
+ export declare const maxLicenseFileBytes: number;
4
+ export declare const checkedDependencies = "repometry.legal.checked-dependencies/v1";
5
+ declare const lockfileKinds: Readonly<{
6
+ readonly 'package-lock.json': 'npm';
7
+ readonly 'npm-shrinkwrap.json': 'npm';
8
+ readonly 'composer.lock': 'composer';
9
+ readonly 'Cargo.lock': 'unverified';
10
+ readonly 'go.sum': 'unverified';
11
+ readonly 'Gemfile.lock': 'unverified';
12
+ readonly 'poetry.lock': 'unverified';
13
+ readonly 'Pipfile.lock': 'unverified';
14
+ readonly 'pnpm-lock.yaml': 'unverified';
15
+ readonly 'yarn.lock': 'unverified';
16
+ readonly 'uv.lock': 'unverified';
17
+ }>;
18
+ export declare const licenseLockNames: string[];
19
+ export declare function licenseLockKind(name: string): typeof lockfileKinds[keyof typeof lockfileKinds] | undefined;
20
+ export declare function isLicenseLockfile(path: string): boolean;
21
+ export declare const licenseImportFormats: readonly ['cyclonedx', 'spdx'];
22
+ export type LicenseImportFormat = typeof licenseImportFormats[number];
23
+ export interface LicenseImportFile extends SourceFile {
24
+ readonly format: LicenseImportFormat;
25
+ }
26
+ export interface LicenseInput {
27
+ readonly format: LicenseImportFormat;
28
+ readonly file: string;
29
+ }
30
+ export interface ImportedLicenseEvidence {
31
+ readonly formats: readonly LicenseImportFormat[];
32
+ readonly files: readonly LicenseImportFile[];
33
+ readonly skipped: readonly {
34
+ readonly path: string;
35
+ readonly message: string;
36
+ }[];
37
+ }
38
+ export type LicenseEvidenceFile = SourceFile & {
39
+ readonly format?: LicenseImportFormat;
40
+ };
41
+ export declare const licenseFiles: DataContract<readonly LicenseEvidenceFile[]>;
42
+ export {};
@@ -0,0 +1,23 @@
1
+ import { sourceFiles } from './snapshot.js';
2
+ export const maxLicenseFileBytes = 64 * 1024 * 1024;
3
+ export const checkedDependencies = 'repometry.legal.checked-dependencies/v1';
4
+ const lockfileKinds = Object.freeze({
5
+ 'package-lock.json': 'npm', 'npm-shrinkwrap.json': 'npm', 'composer.lock': 'composer',
6
+ 'Cargo.lock': 'unverified', 'go.sum': 'unverified', 'Gemfile.lock': 'unverified', 'poetry.lock': 'unverified',
7
+ 'Pipfile.lock': 'unverified', 'pnpm-lock.yaml': 'unverified', 'yarn.lock': 'unverified', 'uv.lock': 'unverified',
8
+ });
9
+ export const licenseLockNames = Object.keys(lockfileKinds);
10
+ export function licenseLockKind(name) {
11
+ return Object.hasOwn(lockfileKinds, name) ? lockfileKinds[name] : undefined;
12
+ }
13
+ export function isLicenseLockfile(path) {
14
+ return licenseLockKind(path.slice(path.lastIndexOf('/') + 1)) !== undefined;
15
+ }
16
+ export const licenseImportFormats = ['cyclonedx', 'spdx'];
17
+ export const licenseFiles = {
18
+ id: 'repometry.license-files/v1',
19
+ accepts: (value) => sourceFiles.accepts(value)
20
+ && value.every(file => file.bytes.byteLength <= maxLicenseFileBytes
21
+ && (!('format' in file) || licenseImportFormats.some(format => format === file.format))),
22
+ };
23
+ //# sourceMappingURL=license-evidence.js.map
@@ -1,6 +1,7 @@
1
1
  import type { Report } from './report.js';
2
2
  export type Grade = 'A' | 'B' | 'C' | 'D' | 'F';
3
3
  export interface QualitySummary {
4
+ readonly legal?: LegalSummary;
4
5
  readonly codeLines: number | null;
5
6
  readonly comments: number | null;
6
7
  readonly classes: number | null;
@@ -29,6 +30,16 @@ interface DebtModel {
29
30
  }
30
31
  export declare const debtModel: DebtModel;
31
32
  export declare function qualitySummary(report: Report): QualitySummary;
33
+ export interface LegalSummary {
34
+ readonly grade: Grade;
35
+ readonly checked: number;
36
+ readonly inputs: number;
37
+ readonly low: number;
38
+ readonly medium: number;
39
+ readonly high: number;
40
+ readonly unknown: number;
41
+ }
42
+ export declare function legalSummary(report: Report): LegalSummary | undefined;
32
43
  export declare function technicalDebtRatio(effortMinutes: number, codeLines: number, model?: DebtModel): number | null;
33
44
  export declare function maintainabilityGrade(debtRatio: number): Grade;
34
45
  export declare function coverageGrade(ratio: number): Grade;
@@ -1,4 +1,5 @@
1
1
  import { isRecord } from './plugin-data.js';
2
+ import { checkedDependencies } from './license-evidence.js';
2
3
  import { canonicalMetricId, definitions } from './measurement.js';
3
4
  export const debtModel = { name: 'basic-cocomo-organic', scale: 2.4, exponent: 1.05, minutesPerPersonMonth: 9600 };
4
5
  export function qualitySummary(report) {
@@ -7,7 +8,9 @@ export function qualitySummary(report) {
7
8
  const completeTotal = (id) => totalMeasured(files.get(id), totalFiles);
8
9
  const codeLines = completeTotal(definitions.codeLines);
9
10
  const duplicatedLines = completeTotal(definitions.duplicatedLines);
11
+ const legal = legalSummary(report);
10
12
  return {
13
+ ...(legal === undefined ? {} : { legal }),
11
14
  codeLines,
12
15
  comments: completeTotal(definitions.comments),
13
16
  classes: completeTotal(definitions.classes),
@@ -17,6 +20,17 @@ export function qualitySummary(report) {
17
20
  maintainability: gradeMeasuredFiles(report, files.get(definitions.codeLines), files.get(definitions.duplicatedLines)),
18
21
  };
19
22
  }
23
+ export function legalSummary(report) {
24
+ const scanned = report.measurements.filter(row => row.definition === checkedDependencies);
25
+ if (!scanned.length)
26
+ return undefined;
27
+ const counts = { low: 0, medium: 0, high: 0, unknown: 0 };
28
+ for (const finding of report.findings ?? []) {
29
+ if (finding.category === 'legal')
30
+ counts[finding.level]++;
31
+ }
32
+ return { ...counts, grade: securityGrade(counts), checked: scanned.reduce((total, row) => total + (row.value ?? 0), 0), inputs: scanned.length };
33
+ }
20
34
  function collectFileMeasures(report) {
21
35
  const files = new Map();
22
36
  for (const { target, path, definition, value } of report.measurements) {
@@ -15,7 +15,7 @@ export declare function isMergedLineRanges(value: unknown): value is readonly So
15
15
  export declare const maxClaimedFileBytes: number;
16
16
  /** How much of a file's start is searched for the NUL byte that marks it as binary. */
17
17
  export declare const binaryProbeBytes = 8192;
18
- export declare function isClaimedText(bytes: Uint8Array): boolean;
18
+ export declare function isClaimedText(bytes: Uint8Array, sizeLimit?: number): boolean;
19
19
  export interface InventoryFile {
20
20
  readonly path: string;
21
21
  readonly lines: number | null;
@@ -16,7 +16,7 @@ export function isMergedLineRanges(value) {
16
16
  export const maxClaimedFileBytes = 1024 * 1024;
17
17
  /** How much of a file's start is searched for the NUL byte that marks it as binary. */
18
18
  export const binaryProbeBytes = 8192;
19
- export function isClaimedText(bytes) {
20
- return bytes.byteLength <= maxClaimedFileBytes && !bytes.subarray(0, binaryProbeBytes).includes(0);
19
+ export function isClaimedText(bytes, sizeLimit = maxClaimedFileBytes) {
20
+ return bytes.byteLength <= sizeLimit && !bytes.subarray(0, binaryProbeBytes).includes(0);
21
21
  }
22
22
  //# sourceMappingURL=source.js.map
@@ -42,9 +42,9 @@ function validateCoverage(plugin, check, path, base) {
42
42
  throw new Error(base + '/path is required for coverage to identify the files to exclude');
43
43
  }
44
44
  function readCategory(value, base) {
45
- if (value === undefined || value === category.maintainability || value === category.security || value === category.coverage)
45
+ if (value === undefined || value === category.maintainability || value === category.security || value === category.coverage || value === category.legal)
46
46
  return value;
47
- throw new Error(base + '/category must be maintainability, coverage or security');
47
+ throw new Error(base + '/category must be maintainability, coverage, security or legal');
48
48
  }
49
49
  function readText(value, path, expectation) {
50
50
  if (value === undefined)
@@ -1,3 +1,4 @@
1
+ import type { ImportedLicenseEvidence } from '../model/license-evidence.js';
1
2
  import type { FindingIgnoreRule } from '../model/finding-ignore.js';
2
3
  import type { Report } from '../model/report.js';
3
4
  import type { SourceSnapshot } from '../model/source.js';
@@ -7,6 +8,7 @@ export interface AnalysisInput {
7
8
  readonly excludedOutput: string | null;
8
9
  readonly excludedPaths?: readonly string[];
9
10
  readonly ignoresCoverage?: (path: string) => boolean;
11
+ readonly licenseImport?: ImportedLicenseEvidence;
10
12
  readonly coverage?: {
11
13
  readonly text: string;
12
14
  readonly sourceRoot: string;
@@ -26,6 +28,7 @@ interface InspectionCoverage {
26
28
  export interface InspectionPorts {
27
29
  readSource(excludes: Excludes): Promise<InspectionSource>;
28
30
  analyze(input: AnalysisInput): Promise<Report>;
31
+ readLicenseImports?(source: Pick<InspectionSource, 'root'>): Promise<ImportedLicenseEvidence>;
29
32
  readCoverage?(source: Pick<InspectionSource, 'root' | 'snapshot'>): Promise<InspectionCoverage>;
30
33
  importFindings?(report: Report, root: string, excludes: Excludes): Promise<Report>;
31
34
  recordChurn?(report: Report, root: string, paths: readonly string[]): Promise<Report>;
@@ -10,9 +10,9 @@ export async function executeInspection(options, ports) {
10
10
  const ignore = recordIgnoreRules(readIgnoreRules(options.ignore ?? []));
11
11
  const source = await ports.readSource(sourceExclusionMatcher(excludedPaths));
12
12
  const { snapshot, root, excludedOutput } = source;
13
- const lcov = await ports.readCoverage?.(source);
13
+ const [lcov, licenseImport] = await Promise.all([ports.readCoverage?.(source), ports.readLicenseImports?.(source)]);
14
14
  const report = await ports.analyze({
15
- snapshot, excludedOutput, excludedPaths, ignoresCoverage: coverageIgnore(ignore),
15
+ snapshot, excludedOutput, excludedPaths, ...(licenseImport === undefined ? {} : { licenseImport }), ignoresCoverage: coverageIgnore(ignore),
16
16
  coverage: lcov === undefined ? undefined : { text: lcov.text, sourceRoot: root },
17
17
  });
18
18
  if (report.subject.kind !== snapshot.subject.kind || report.subject.id !== snapshot.subject.id) {
@@ -34,9 +34,11 @@ export async function executeInspection(options, ports) {
34
34
  function applyIgnore(report, ignore) {
35
35
  if (ignore.length === 0)
36
36
  return report;
37
+ const active = report.findings === undefined ? undefined : partitionFindings(report.findings, ignore);
37
38
  return { ...report, schema: reportSchema,
38
39
  appliedConfig: { ...report.appliedConfig, findingIgnore: ignore },
39
- ...(report.findings === undefined ? {} : partitionFindings(report.findings, ignore)) };
40
+ ...(active === undefined ? {} : { findings: active.findings,
41
+ ignoredFindings: [...report.ignoredFindings ?? [], ...active.ignoredFindings] }) };
40
42
  }
41
43
  function withLcovDigests(report, { text, inputDigests }) {
42
44
  const coverage = report.appliedConfig.coverage;