Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/adding_new_strategy.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ You will obviously need to add your own `.ts` file in the **src/strategies** fol

```ts
// Import Internal Dependencies
import { VULN_MODE } from "../constants.js";
import type { Dependencies } from "./types/scanner.js";
import { VULN_MODE } from "../constants.ts";
import type { Dependencies } from "./types/scanner.ts";
import type {
HydratePayloadDepsOptions,
BaseStrategy
} from "./types/api.js";
} from "./types/api.ts";

export type FooBarStrategyDefinition = BaseStrategy<"foobar">;

Expand Down
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"build": "tsc",
"prepublishOnly": "npm run build",
"lint": "eslint src test",
"test-only": "glob -c \"tsx --test\" \"./test/**/*.spec.ts\"",
"unit-test-only": "glob -c \"tsx --test\" \"./test/**/*.unit.spec.ts\"",
"integration-test-only": "glob -c \"tsx --test\" \"./test/**/*.integration.spec.ts\"",
"test-only": "node --test ./test/**/*.spec.ts",
"unit-test-only": "node --test ./test/**/*.unit.spec.ts",
"integration-test-only": "node --test ./test/**/*.integration.spec.ts",
"test": "npm run lint && npm run test-only",
"test:unit": "npm run lint && npm run unit-test-only",
"test:integration": "npm run lint && npm run integration-test-only",
Expand Down Expand Up @@ -47,13 +47,10 @@
"homepage": "https://github.com/NodeSecure/vulnera#readme",
"devDependencies": {
"@openally/config.eslint": "^2.1.0",
"@openally/config.typescript": "^1.0.3",
"@openally/config.typescript": "1.2.1",
"@slimio/is": "^2.0.0",
"@types/node": "^24.0.1",
"c8": "^10.1.2",
"cross-env": "^10.0.0",
"glob": "^11.0.0",
"tsx": "^4.7.0",
"typescript": "^5.4.2"
},
"dependencies": {
Expand Down
8 changes: 4 additions & 4 deletions src/database/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * as osv from "./osv.js";
export * as snyk from "./snyk.js";
export * as nvd from "./nvd.js";
export * as sonatype from "./sonatype.js";
export * as osv from "./osv.ts";
export * as snyk from "./snyk.ts";
export * as nvd from "./nvd.ts";
export * as sonatype from "./sonatype.ts";
4 changes: 2 additions & 2 deletions src/database/nvd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import * as httpie from "@openally/httpie";

// Import Internal Dependencies
import * as utils from "../utils.js";
import type { NVD } from "../formats/nvd/index.js";
import * as utils from "../utils.ts";
import type { NVD } from "../formats/nvd/index.ts";

// CONSTANTS
export const ROOT_API = "https://services.nvd.nist.gov/rest/json/cves/2.0";
Expand Down
4 changes: 2 additions & 2 deletions src/database/osv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import * as httpie from "@openally/httpie";

// Import Internal Dependencies
import type { OSV } from "../formats/osv/index.js";
import * as utils from "../utils.js";
import type { OSV } from "../formats/osv/index.ts";
import * as utils from "../utils.ts";

// CONSTANTS
export const ROOT_API = "https://api.osv.dev";
Expand Down
4 changes: 2 additions & 2 deletions src/database/snyk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import * as httpie from "@openally/httpie";

// Import Internal Dependencies
import { SNYK_ORG, SNYK_TOKEN } from "../constants.js";
import type { SnykAuditResponse } from "../formats/snyk/index.js";
import { SNYK_ORG, SNYK_TOKEN } from "../constants.ts";
import type { SnykAuditResponse } from "../formats/snyk/index.ts";

// CONSTANTS
export const ROOT_API = "https://snyk.io";
Expand Down
2 changes: 1 addition & 1 deletion src/database/sonatype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as httpie from "@openally/httpie";

// Import Internal Dependencies
import type { SonatypeResponse } from "../formats/sonatype/index.js";
import type { SonatypeResponse } from "../formats/sonatype/index.ts";

export type SonaTypeFindOneParameters = {
coordinates: string[];
Expand Down
4 changes: 2 additions & 2 deletions src/formats/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Import Internal Dependencies
import type { BaseStrategyFormat } from "../strategies/types/api.js";
import type { BaseStrategyFormat } from "../strategies/types/api.ts";

import {
standardVulnerabilityMapper,
type StandardizeKind
} from "./standard/index.js";
} from "./standard/index.ts";

export function formatVulnsPayload(
format: BaseStrategyFormat | null = null
Expand Down
4 changes: 2 additions & 2 deletions src/formats/standard/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Import Internal Dependencies
import { STANDARD_VULN_MAPPERS } from "./mappers.js";
import type { Kind } from "../../constants.js";
import { STANDARD_VULN_MAPPERS } from "./mappers.ts";
import type { Kind } from "../../constants.ts";

export type Severity = "info" | "low" | "medium" | "high" | "critical";

Expand Down
8 changes: 3 additions & 5 deletions src/formats/standard/mappers.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// Import Internal Dependencies
import { VULN_MODE } from "../../constants.js";
import * as utils from "../../utils.js";

// Import types
import { VULN_MODE } from "../../constants.ts";
import * as utils from "../../utils.ts";
import type {
SonatypeVulnerability,
SnykVulnerability,
NpmAuditAdvisory,
PnpmAuditAdvisory,
StandardVulnerability
} from "../../index.js";
} from "../../index.ts";

function mapFromNPM(vuln: NpmAuditAdvisory): StandardVulnerability {
const hasCVSS = typeof vuln.cvss !== "undefined";
Expand Down
22 changes: 11 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,52 @@ import {
type GithubVulnerability,
type NpmAuditAdvisory,
type PnpmAuditAdvisory
} from "./strategies/github-advisory.js";
} from "./strategies/github-advisory.ts";

import {
SnykStrategy,
type SnykStrategyDefinition
} from "./strategies/snyk.js";
} from "./strategies/snyk.ts";

import {
SonatypeStrategy,
type SonatypeStrategyDefinition,
type SonatypeVulnerability
} from "./strategies/sonatype.js";
} from "./strategies/sonatype.ts";

import {
NoneStrategy,
type NoneStrategyDefinition
} from "./strategies/none.js";
} from "./strategies/none.ts";

import {
VULN_MODE,
type Kind
} from "./constants.js";
} from "./constants.ts";

import type {
SnykVulnerability
} from "./formats/snyk/index.js";
} from "./formats/snyk/index.ts";
import type {
StandardVulnerability, Severity, StandardPatch
} from "./formats/standard/index.js";
} from "./formats/standard/index.ts";
import type {
OSV
} from "./formats/osv/index.js";
} from "./formats/osv/index.ts";

import type {
Dependencies
} from "./strategies/types/scanner.js";
} from "./strategies/types/scanner.ts";

import type {
BaseStrategy,
BaseStrategyOptions,
BaseStrategyFormat,
ExtendedStrategy,
HydratePayloadDepsOptions
} from "./strategies/types/api.js";
} from "./strategies/types/api.ts";

export * as Database from "./database/index.js";
export * as Database from "./database/index.ts";

export type AllStrategy = {
none: NoneStrategyDefinition;
Expand Down
10 changes: 5 additions & 5 deletions src/strategies/github-advisory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import { getLocalRegistryURL } from "@nodesecure/npm-registry-sdk";
import { readWantedLockfile } from "@pnpm/lockfile-file";

// Import Internal Dependencies
import { VULN_MODE, NPM_TOKEN } from "../constants.js";
import type { StandardVulnerability } from "../formats/standard/index.js";
import { formatVulnsPayload } from "../formats/index.js";
import type { Dependencies } from "./types/scanner.js";
import { VULN_MODE, NPM_TOKEN } from "../constants.ts";
import type { StandardVulnerability } from "../formats/standard/index.ts";
import { formatVulnsPayload } from "../formats/index.ts";
import type { Dependencies } from "./types/scanner.ts";
import type {
BaseStrategyOptions,
ExtendedStrategy,
HydratePayloadDepsOptions
} from "./types/api.js";
} from "./types/api.ts";

export type NpmAuditAdvisory = {
/** The unique cache key for this vuln or metavuln. **/
Expand Down
4 changes: 2 additions & 2 deletions src/strategies/none.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Import Internal Dependencies
import { VULN_MODE } from "../constants.js";
import type { BaseStrategy } from "./types/api.js";
import { VULN_MODE } from "../constants.ts";
import type { BaseStrategy } from "./types/api.ts";

export type NoneStrategyDefinition = BaseStrategy<"none">;

Expand Down
12 changes: 6 additions & 6 deletions src/strategies/snyk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import path from "node:path";
import { readFile } from "node:fs/promises";

// Import Internal Dependencies
import { VULN_MODE } from "../constants.js";
import type { Dependencies } from "./types/scanner.js";
import { VULN_MODE } from "../constants.ts";
import type { Dependencies } from "./types/scanner.ts";
import type {
HydratePayloadDepsOptions,
BaseStrategy
} from "./types/api.js";
import { type SnykAuditResponse } from "../formats/snyk/index.js";
import { snyk } from "../database/index.js";
import { formatVulnsPayload } from "../formats/index.js";
} from "./types/api.ts";
import { type SnykAuditResponse } from "../formats/snyk/index.ts";
import { snyk } from "../database/index.ts";
import { formatVulnsPayload } from "../formats/index.ts";

export type SnykStrategyDefinition = BaseStrategy<"snyk">;

Expand Down
12 changes: 6 additions & 6 deletions src/strategies/sonatype.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Import Internal Dependencies
import * as utils from "../utils.js";
import { VULN_MODE } from "../constants.js";
import type { Dependencies, Dependency } from "./types/scanner.js";
import * as utils from "../utils.ts";
import { VULN_MODE } from "../constants.ts";
import type { Dependencies, Dependency } from "./types/scanner.ts";
import type {
BaseStrategyOptions,
BaseStrategy
} from "./types/api.js";
import { formatVulnsPayload } from "../formats/index.js";
import { sonatype } from "../database/index.js";
} from "./types/api.ts";
import { formatVulnsPayload } from "../formats/index.ts";
import { sonatype } from "../database/index.ts";

// CONSTANTS
const kRatelimitChunkSize = 128;
Expand Down
6 changes: 3 additions & 3 deletions src/strategies/types/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Import Internal Dependencies
import type { Dependencies } from "./scanner.js";
import type { StandardVulnerability } from "../../formats/standard/index.js";
import type { Kind } from "../../constants.js";
import type { Dependencies } from "./scanner.ts";
import type { StandardVulnerability } from "../../formats/standard/index.ts";
import type { Kind } from "../../constants.ts";

export type BaseStrategyFormat = "Standard";

Expand Down
2 changes: 1 addition & 1 deletion src/strategies/types/scanner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Import Internal Dependencies
import type { StandardVulnerability } from "../../formats/standard/index.js";
import type { StandardVulnerability } from "../../formats/standard/index.ts";

export interface Dependency {
metadata: any;
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Import Internal Dependencies
import type { Severity } from "./formats/standard/index.js";
import type { Severity } from "./formats/standard/index.ts";

export function fromMaybeStringToArray(
value: undefined | null | string | string[]
Expand Down
4 changes: 2 additions & 2 deletions test/database/nvd.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import assert from "node:assert";
import {
HTTP_CLIENT_HEADERS,
setupHttpAgentMock
} from "../strategies/utils.js";
import { nvd } from "../../src/database/index.js";
} from "../strategies/utils.ts";
import { nvd } from "../../src/database/index.ts";

describe("nvd", () => {
const [mockedHttpAgent, restoreHttpAgent] = setupHttpAgentMock();
Expand Down
4 changes: 2 additions & 2 deletions test/database/osv.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import assert from "node:assert";
import {
HTTP_CLIENT_HEADERS,
setupHttpAgentMock
} from "../strategies/utils";
import { osv } from "../../src/database/index";
} from "../strategies/utils.ts";
import { osv } from "../../src/database/index.ts";

describe("osv", () => {
const [mockedHttpAgent, restoreHttpAgent] = setupHttpAgentMock();
Expand Down
6 changes: 3 additions & 3 deletions test/database/snyk.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { describe, test, after } from "node:test";
import assert from "node:assert";

// Import Internal Dependencies
import { HTTP_CLIENT_HEADERS, setupHttpAgentMock } from "../strategies/utils";
import { snyk } from "../../src/database";
import { SNYK_ORG } from "../../src/constants";
import { HTTP_CLIENT_HEADERS, setupHttpAgentMock } from "../strategies/utils.ts";
import { snyk } from "../../src/database/index.ts";
import { SNYK_ORG } from "../../src/constants.ts";

describe("snyk", () => {
const [mockedHttpAgent, restoreHttpAgent] = setupHttpAgentMock();
Expand Down
4 changes: 2 additions & 2 deletions test/database/sonatype.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import assert from "node:assert";
import {
HTTP_CLIENT_HEADERS,
setupHttpAgentMock
} from "../strategies/utils";
import { sonatype } from "../../src/database/index";
} from "../strategies/utils.ts";
import { sonatype } from "../../src/database/index.ts";

describe("sonatype", () => {
const [mockedHttpAgent, restoreHttpAgent] = setupHttpAgentMock();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { SNYK_VULNERABILITY, NPM_VULNERABILITY, SONATYPE_VULNERABILITY } from "./vulns.js";
// Import Internal Dependencies
import {
SNYK_VULNERABILITY,
NPM_VULNERABILITY,
SONATYPE_VULNERABILITY
} from "./vulns.ts";

export const NPM_VULNS_PAYLOADS = {
inputVulnsPayload: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

/* eslint-disable @stylistic/max-len */

export const NPM_VULNERABILITY = {
title: "Arbitrary Command Injection due to Improper Command Sanitization",
name: "@npmcli/git",
Expand Down
9 changes: 7 additions & 2 deletions test/strategies/github_advisory_npm/index.integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ import { test } from "node:test";
import assert from "node:assert";

// Import Internal Dependencies
import { GitHubAdvisoryStrategy, NpmAuditAdvisory } from "../../../src/strategies/github-advisory.js";
import { expectVulnToBeNodeSecureStandardCompliant } from "../utils.js";
import {
GitHubAdvisoryStrategy,
type NpmAuditAdvisory
} from "../../../src/strategies/github-advisory.ts";
import {
expectVulnToBeNodeSecureStandardCompliant
} from "../utils.ts";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
Expand Down
2 changes: 1 addition & 1 deletion test/strategies/github_advisory_npm/index.unit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { test } from "node:test";
import assert from "node:assert";

// Import Internal Dependencies
import { GitHubAdvisoryStrategy } from "../../../src/strategies/github-advisory.js";
import { GitHubAdvisoryStrategy } from "../../../src/strategies/github-advisory.ts";

test("GitHubAdvisoryStrategy definition must return only three keys.", () => {
const definition = GitHubAdvisoryStrategy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { test } from "node:test";
import assert from "node:assert";

// Import Internal Dependencies
import { GitHubAdvisoryStrategy, PnpmAuditAdvisory } from "../../../src/strategies/github-advisory.js";
import { expectVulnToBeNodeSecureStandardCompliant } from "../utils.js";
import {
GitHubAdvisoryStrategy,
type PnpmAuditAdvisory
} from "../../../src/strategies/github-advisory.ts";
import { expectVulnToBeNodeSecureStandardCompliant } from "../utils.ts";

// CONSTANTS
const __dirname = path.dirname(fileURLToPath(import.meta.url));
Expand Down
Loading
Loading