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
5 changes: 5 additions & 0 deletions .changeset/ripe-wombats-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nodesecure/scanner": patch
---

remove faulty manifestAuthor helper for utils.parseAuthor
6 changes: 3 additions & 3 deletions workspaces/scanner/src/depWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { Mutex, MutexRelease } from "@openally/mutex";
import { scanDirOrArchive, type scanDirOrArchiveOptions } from "@nodesecure/tarball";
import * as Vulnera from "@nodesecure/vulnera";
import { npm } from "@nodesecure/tree-walker";
import { parseAuthor } from "@nodesecure/utils";
import type { ManifestVersion, PackageJSON } from "@nodesecure/npm-types";

// Import Internal Dependencies
import {
getDependenciesWarnings,
addMissingVersionFlags,
getUsedDeps,
manifestAuthor,
getManifestLinks
} from "./utils/index.js";
import { packageMetadata, manifestMetadata } from "./npmRegistry.js";
Expand Down Expand Up @@ -240,12 +240,12 @@ export async function depWalker(

if (isLocalManifest(verDescriptor, manifest, packageName)) {
Object.assign(dependency.metadata, {
author: manifestAuthor(manifest.author),
author: parseAuthor(manifest.author),
homepage: manifest.homepage
});

Object.assign(verDescriptor, {
author: manifestAuthor(manifest.author),
author: parseAuthor(manifest.author),
links: getManifestLinks(manifest),
repository: manifest.repository
});
Expand Down
1 change: 0 additions & 1 deletion workspaces/scanner/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export * from "./addMissingVersionFlags.js";
export * from "./getLinks.js";
export * from "./urlToString.js";
export * from "./getUsedDeps.js";
export * from "./manifestAuthor.js";
export * from "./isNodesecurePayload.js";

export const NPM_TOKEN = typeof process.env.NODE_SECURE_TOKEN === "string" ?
Expand Down
21 changes: 0 additions & 21 deletions workspaces/scanner/src/utils/manifestAuthor.ts

This file was deleted.

58 changes: 33 additions & 25 deletions workspaces/scanner/test/depWalker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import path from "node:path";
import url from "node:url";
import { readFileSync } from "node:fs";
import { test } from "node:test";
import { test, describe } from "node:test";
import assert from "node:assert";

// Import Third-party Dependencies
Expand Down Expand Up @@ -196,31 +196,39 @@ test("highlight contacts from a remote package", async() => {
);
});

test("should parse author, homepage and links for non-npm package", async() => {
const result = await cwd(path.join(kFixturePath, "non-npm-package"));

const dep = result.dependencies["non-npm-package"];
const v1 = dep.versions["1.0.0"];

assert.deepEqual(v1.author, {
email: void 0,
name: "NodeSecure",
url: void 0
});
assert.deepStrictEqual(v1.links, {
npm: null,
homepage: "https://nodesecure.com",
repository: "https://github.com/NodeSecure/non-npm-package"
});
assert.deepStrictEqual(v1.repository, {
type: "git",
url: "https://github.com/NodeSecure/non-npm-package.git"
describe("scanner.cwd()", () => {
test("should parse author, homepage and links for a local package who doesn't exist on the remote registry", async() => {
const result = await cwd(path.join(kFixturePath, "non-npm-package"));

const dep = result.dependencies["non-npm-package"];
const v1 = dep.versions["1.0.0"];

assert.deepEqual(v1.author, {
name: "NodeSecure"
});
assert.deepStrictEqual(v1.links, {
npm: null,
homepage: "https://nodesecure.com",
repository: "https://github.com/NodeSecure/non-npm-package"
});
assert.deepStrictEqual(v1.repository, {
type: "git",
url: "https://github.com/NodeSecure/non-npm-package.git"
});

assert.deepStrictEqual(dep.metadata.author, {
name: "NodeSecure"
});
assert.strictEqual(dep.metadata.homepage, "https://nodesecure.com");
});

assert.deepStrictEqual(dep.metadata.author, {
email: void 0,
name: "NodeSecure",
url: void 0
test("should parse local manifest author field without throwing when attempting to highlight contacts", async() => {
const { dependencies } = await cwd(
path.join(kFixturePath, "non-valid-authors")
);
const pkg = dependencies["random-package"];

assert.strictEqual(pkg.metadata.author, null);
});
assert.strictEqual(dep.metadata.homepage, "https://nodesecure.com");
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "random-package",
"type": "module",
"author": "John Doe <john.doe@gmail.com>, Alicia B <alicia@gmail.com>"
}
50 changes: 0 additions & 50 deletions workspaces/scanner/test/utils/manifestAuthor.spec.ts

This file was deleted.