@shieldaai/security-watch 0.0.0-stage → 0.1.0-alpha.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.
Files changed (62) hide show
  1. package/CONTRIBUTING.md +90 -0
  2. package/LICENSE +202 -0
  3. package/README.md +269 -2
  4. package/SECURITY.md +47 -0
  5. package/dist/assessment.d.ts +5 -0
  6. package/dist/assessment.js +398 -0
  7. package/dist/cli.d.ts +2 -0
  8. package/dist/cli.js +792 -0
  9. package/dist/config.d.ts +242 -0
  10. package/dist/config.js +298 -0
  11. package/dist/cve-now.d.ts +5 -0
  12. package/dist/cve-now.js +413 -0
  13. package/dist/delivery.d.ts +26 -0
  14. package/dist/delivery.js +394 -0
  15. package/dist/ecosystems.d.ts +25 -0
  16. package/dist/ecosystems.js +254 -0
  17. package/dist/engine.d.ts +26 -0
  18. package/dist/engine.js +307 -0
  19. package/dist/health.d.ts +17 -0
  20. package/dist/health.js +70 -0
  21. package/dist/heartbeat.d.ts +13 -0
  22. package/dist/heartbeat.js +74 -0
  23. package/dist/http.d.ts +8 -0
  24. package/dist/http.js +251 -0
  25. package/dist/index.d.ts +18 -0
  26. package/dist/index.js +15 -0
  27. package/dist/inventory.d.ts +3 -0
  28. package/dist/inventory.js +143 -0
  29. package/dist/lock.d.ts +3 -0
  30. package/dist/lock.js +112 -0
  31. package/dist/maintenance.d.ts +43 -0
  32. package/dist/maintenance.js +227 -0
  33. package/dist/models.d.ts +20 -0
  34. package/dist/models.js +602 -0
  35. package/dist/operations.d.ts +17 -0
  36. package/dist/operations.js +117 -0
  37. package/dist/providers.d.ts +209 -0
  38. package/dist/providers.js +459 -0
  39. package/dist/setup.d.ts +113 -0
  40. package/dist/setup.js +100 -0
  41. package/dist/source-error.d.ts +22 -0
  42. package/dist/source-error.js +56 -0
  43. package/dist/sources.d.ts +3 -0
  44. package/dist/sources.js +1071 -0
  45. package/dist/store.d.ts +71 -0
  46. package/dist/store.js +651 -0
  47. package/dist/types.d.ts +247 -0
  48. package/dist/types.js +1 -0
  49. package/dist/util.d.ts +6 -0
  50. package/dist/util.js +14 -0
  51. package/dist/vendor-sources.d.ts +24 -0
  52. package/dist/vendor-sources.js +56 -0
  53. package/docs/configuration.md +406 -0
  54. package/docs/quality-review.md +104 -0
  55. package/examples/advisories.json +17 -0
  56. package/examples/common-systems.yaml +243 -0
  57. package/examples/libraries.example.txt +16 -0
  58. package/examples/libraries.example.yaml +38 -0
  59. package/examples/library-watch.example.yaml +27 -0
  60. package/examples/security-watch.example.yaml +86 -0
  61. package/examples/systems.example.yaml +31 -0
  62. package/package.json +69 -4
@@ -0,0 +1,22 @@
1
+ import type { Evidence } from './types.js';
2
+ /** Source diagnostics safe to display without exposing transport credentials. */
3
+ export declare class SourceError extends Error {
4
+ }
5
+ export declare class SourceHttpError extends SourceError {
6
+ readonly status: number;
7
+ constructor(source: string, status: number);
8
+ }
9
+ export declare function sourceCanceled(error: unknown): boolean;
10
+ export declare class PartialSourceError extends SourceError {
11
+ readonly evidence: Evidence[];
12
+ constructor(message: string, evidence: Evidence[]);
13
+ }
14
+ export declare function throwSourceFailure(error: unknown, evidence: Evidence[]): never;
15
+ /** Isolate malformed records without accepting a partially validated record. */
16
+ export declare class SourceItemFailures {
17
+ private count;
18
+ private first;
19
+ read<T>(parse: () => T): T | undefined;
20
+ message(source: string): string | undefined;
21
+ finish(source: string, evidence: Evidence[]): Evidence[];
22
+ }
@@ -0,0 +1,56 @@
1
+ /** Source diagnostics safe to display without exposing transport credentials. */
2
+ export class SourceError extends Error {
3
+ }
4
+ export class SourceHttpError extends SourceError {
5
+ status;
6
+ constructor(source, status) {
7
+ super(`${source} returned HTTP ${status}.`);
8
+ this.status = status;
9
+ }
10
+ }
11
+ export function sourceCanceled(error) {
12
+ return (error instanceof Error &&
13
+ (error.name === 'AbortError' ||
14
+ ('code' in error && ['ABORT_ERR', 'REQUEST_ABORTED'].includes(String(error.code)))));
15
+ }
16
+ export class PartialSourceError extends SourceError {
17
+ evidence;
18
+ constructor(message, evidence) {
19
+ super(message);
20
+ this.evidence = evidence;
21
+ }
22
+ }
23
+ export function throwSourceFailure(error, evidence) {
24
+ if (sourceCanceled(error) || !evidence.length || error instanceof PartialSourceError)
25
+ throw error;
26
+ const message = error instanceof SourceError ? error.message : 'Source request failed.';
27
+ throw new PartialSourceError(`${message} Valid records were retained; collection remains incomplete and its checkpoint was not advanced.`, evidence);
28
+ }
29
+ /** Isolate malformed records without accepting a partially validated record. */
30
+ export class SourceItemFailures {
31
+ count = 0;
32
+ first;
33
+ read(parse) {
34
+ try {
35
+ return parse();
36
+ }
37
+ catch (error) {
38
+ if (!(error instanceof SourceError) || error instanceof PartialSourceError)
39
+ throw error;
40
+ this.count++;
41
+ this.first ??= error.message;
42
+ return undefined;
43
+ }
44
+ }
45
+ message(source) {
46
+ return this.count
47
+ ? `${source}: ${this.count} invalid item(s) were skipped. ${this.first} Collection remains incomplete and its checkpoint was not advanced.`
48
+ : undefined;
49
+ }
50
+ finish(source, evidence) {
51
+ const message = this.message(source);
52
+ if (message)
53
+ throw new PartialSourceError(message, evidence);
54
+ return evidence;
55
+ }
56
+ }
@@ -0,0 +1,3 @@
1
+ import type { Config, Evidence, HttpClient, Inventory, SourceResult } from './types.js';
2
+ /** Collect source evidence and report failures without advancing failed sources' checkpoints. */
3
+ export declare function collectSources(inventory: Inventory, config: Config, checkpoints: Record<string, string>, http: HttpClient, now?: number, previousEvidence?: Evidence[]): Promise<SourceResult>;