From b6fab01428ce006ad21ecfe1c4ddfa12ee6865ff Mon Sep 17 00:00:00 2001 From: "Thomas.G" Date: Sun, 14 Jul 2024 11:38:05 +0200 Subject: [PATCH] refactor(scanner): add new highlight + contacts property (#233) --- package-lock.json | 6 ++++++ package.json | 1 + src/index.ts | 2 +- src/projects/scanner.ts | 19 +++++++++--------- src/rc.ts | 20 ++++++++++++++----- src/schema/defs/{author.json => contact.json} | 5 ++++- src/schema/defs/scanner.json | 17 +++++++++++----- 7 files changed, 48 insertions(+), 22 deletions(-) rename src/schema/defs/{author.json => contact.json} (71%) diff --git a/package-lock.json b/package-lock.json index 4df015d..41cf70d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@nodesecure/i18n": "^4.0.0", "@nodesecure/js-x-ray": "^7.0.0", + "@nodesecure/npm-types": "^1.0.0", "@nodesecure/vuln": "^1.7.0", "@openally/result": "^1.2.1", "@slimio/config": "^1.2.0", @@ -1781,6 +1782,11 @@ "@npm/types": "^1.0.2" } }, + "node_modules/@nodesecure/npm-types": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@nodesecure/npm-types/-/npm-types-1.0.0.tgz", + "integrity": "sha512-FEoVZYaU2PhhxzoECUN/zlL5Cgw+Rt/ocZVVx6WIzQE+r0teULvIsRjclbEfG+gDewIlijOYxZXbZQT5PsWevA==" + }, "node_modules/@nodesecure/sec-literal": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@nodesecure/sec-literal/-/sec-literal-1.2.0.tgz", diff --git a/package.json b/package.json index c64798d..f1f9fd0 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "dependencies": { "@nodesecure/i18n": "^4.0.0", "@nodesecure/js-x-ray": "^7.0.0", + "@nodesecure/npm-types": "^1.0.0", "@nodesecure/vuln": "^1.7.0", "@openally/result": "^1.2.1", "@slimio/config": "^1.2.0", diff --git a/src/index.ts b/src/index.ts index 9e71cc4..6c582b4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,4 +3,4 @@ export * from "./functions/write.js"; export * from "./functions/memoize.js"; export * as CONSTANTS from "./constants.js"; -export { type RC, type Author, JSONSchema, homedir } from "./rc.js"; +export { type RC, JSONSchema, homedir } from "./rc.js"; diff --git a/src/projects/scanner.ts b/src/projects/scanner.ts index 22219b2..067e9e8 100644 --- a/src/projects/scanner.ts +++ b/src/projects/scanner.ts @@ -1,22 +1,21 @@ +// Import Third-party Dependencies +import type { Contact } from "@nodesecure/npm-types"; + /** * Configuration dedicated for NodeSecure scanner * @see https://github.com/NodeSecure/scanner */ export interface ScannerConfiguration { - /** - * List of NPM users/authors flagged - * @see https://github.com/NodeSecure/authors - */ - flaggedAuthors: Author[]; -} -export type Author = { - name: string, - email: string, + highlight?: { + contacts: Contact[]; + } } export function generateScannerConfiguration(): { scanner: ScannerConfiguration } { const scanner: ScannerConfiguration = { - flaggedAuthors: [] + highlight: { + contacts: [] + } }; return { scanner }; diff --git a/src/rc.ts b/src/rc.ts index cdd47eb..c2ea76d 100644 --- a/src/rc.ts +++ b/src/rc.ts @@ -10,9 +10,20 @@ import * as vuln from "@nodesecure/vuln"; import { GLOBAL_CONFIGURATION_DIRECTORY } from "./constants.js"; import { loadJSONSchemaSync } from "./schema/loader.js"; -import { generateCIConfiguration, type CiConfiguration, type CiWarnings } from "./projects/ci.js"; -import { generateReportConfiguration, type ReportConfiguration, type ReportChart } from "./projects/report.js"; -import { generateScannerConfiguration, type ScannerConfiguration, type Author } from "./projects/scanner.js"; +import { + generateCIConfiguration, + type CiConfiguration, + type CiWarnings +} from "./projects/ci.js"; +import { + generateReportConfiguration, + type ReportConfiguration, + type ReportChart +} from "./projects/report.js"; +import { + generateScannerConfiguration, + type ScannerConfiguration +} from "./projects/scanner.js"; // CONSTANTS export const JSONSchema = loadJSONSchemaSync(); @@ -91,6 +102,5 @@ export { ReportChart, generateScannerConfiguration, - ScannerConfiguration, - Author + ScannerConfiguration }; diff --git a/src/schema/defs/author.json b/src/schema/defs/contact.json similarity index 71% rename from src/schema/defs/author.json rename to src/schema/defs/contact.json index 4f8eed6..64c287a 100644 --- a/src/schema/defs/author.json +++ b/src/schema/defs/contact.json @@ -6,8 +6,11 @@ }, "email": { "type": "string" + }, + "url": { + "type": "string" } }, - "required": ["name", "email"], + "required": ["name"], "additionalProperties": false } diff --git a/src/schema/defs/scanner.json b/src/schema/defs/scanner.json index a5e66e0..3fde706 100644 --- a/src/schema/defs/scanner.json +++ b/src/schema/defs/scanner.json @@ -1,11 +1,18 @@ { "type": "object", "properties": { - "flaggedAuthors": { - "type": "array", - "items": { - "$ref": "#/$defs/author" - } + "highlight": { + "type": "object", + "properties": { + "contacts": { + "type": "array", + "items": { + "$ref": "#/$defs/contact" + } + } + }, + "required": ["contacts"], + "additionalProperties": false } }, "additionalProperties": false