Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
refactor(scanner): add new highlight + contacts property (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
fraxken authored Jul 14, 2024
1 parent d899091 commit b6fab01
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 22 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
19 changes: 9 additions & 10 deletions src/projects/scanner.ts
Original file line number Diff line number Diff line change
@@ -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 };
Expand Down
20 changes: 15 additions & 5 deletions src/rc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -91,6 +102,5 @@ export {
ReportChart,

generateScannerConfiguration,
ScannerConfiguration,
Author
ScannerConfiguration
};
5 changes: 4 additions & 1 deletion src/schema/defs/author.json → src/schema/defs/contact.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
},
"email": {
"type": "string"
},
"url": {
"type": "string"
}
},
"required": ["name", "email"],
"required": ["name"],
"additionalProperties": false
}
17 changes: 12 additions & 5 deletions src/schema/defs/scanner.json
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b6fab01

Please sign in to comment.