Skip to content

Commit

Permalink
chore: update dependencies & fix broken codes
Browse files Browse the repository at this point in the history
  • Loading branch information
fraxken committed Nov 25, 2023
1 parent e70ce9c commit 7e910c3
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 32 deletions.
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@
"@nodesecure/flags": "^2.4.0",
"@nodesecure/i18n": "^3.2.2",
"@nodesecure/npm-registry-sdk": "^1.6.1",
"@nodesecure/ossf-scorecard-sdk": "^2.0.0",
"@nodesecure/rc": "^1.4.0",
"@nodesecure/scanner": "^4.0.0",
"@nodesecure/ossf-scorecard-sdk": "^3.0.0",
"@nodesecure/rc": "^1.5.0",
"@nodesecure/scanner": "^5.0.1",
"@nodesecure/utils": "^1.1.0",
"@nodesecure/vuln": "^1.7.0",
"@openally/result": "^1.2.0",
Expand All @@ -94,6 +94,7 @@
"filenamify": "^6.0.0",
"ini": "^4.1.1",
"kleur": "^4.1.5",
"markdown-it": "^13.0.2",
"ms": "^2.1.3",
"open": "^9.1.0",
"polka": "^0.5.2",
Expand All @@ -102,6 +103,8 @@
"semver": "^7.5.4",
"server-destroy": "^1.0.1",
"sirv": "^2.0.3",
"vis-data": "^7.1.9",
"vis-network": "^9.1.9",
"zup": "0.0.1"
}
}
10 changes: 5 additions & 5 deletions public/css/components/package/box.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ section#package-info .box-file-info>.box-header>span.Information {
background: #0288d1ab;
}

section#package-info .box-file-info>.box-header>a {
section#package-info .box-file-info>.box-header>.box-title {
font-size: 18px;
font-variant: small-caps;
font-family: "mononoki";
Expand All @@ -61,22 +61,22 @@ section#package-info .box-file-info>.box-header>a:hover {
cursor: pointer;
}

section#package-info .box-file-info>.box-header>p {
section#package-info .box-file-info>.box-header>.box-file {
margin-left: auto;
color: #B3E5FC;
display: flex;
}

section#package-info .box-file-info>.box-header>p a {
section#package-info .box-file-info>.box-header>.box-file a {
color: inherit;
text-decoration: none;
}

section#package-info .box-file-info>.box-header>p a:hover {
section#package-info .box-file-info>.box-header>.box-file a:hover {
text-decoration: underline;
}

section#package-info .box-file-info>.box-header>p i {
section#package-info .box-file-info>.box-header>.box-file i {
margin-right: 6px;
}

Expand Down
6 changes: 4 additions & 2 deletions public/js/components/package/pannels/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ export class Overview {

get author() {
const author = this.package.dependencyVersion.author;
const flatAuthorFullname = typeof author === "string" ? author : (author?.name ?? "Unknown");
if (author === null) {
return "Unknown";
}

return flatAuthorFullname.length > 26 ? `${flatAuthorFullname.slice(0, 26)}...` : flatAuthorFullname;
return author.name.length > 26 ? `${author.name.slice(0, 26)}...` : author.name;
}

/**
Expand Down
25 changes: 17 additions & 8 deletions public/js/components/package/pannels/warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class Warnings {
this.package = pkg;
}

get isLocalProject() {
get isPrincipalRootProject() {
return this.package.currentNode === 0 ||
this.package.dependencyVersion.flags.includes("isGit");
}
Expand Down Expand Up @@ -55,9 +55,6 @@ export class Warnings {
if (window.settings.warnings.has(warning.kind)) {
continue;
}
const multipleLocation = warning.kind === "encoded-literal" ?
warning.location.map((loc) => locationToString(loc)).join(" // ") :
locationToString(warning.location);

const id = Math.random().toString(36).slice(2);
const hasNoInspection =
Expand All @@ -72,7 +69,7 @@ export class Warnings {
]
});

if (this.isLocalProject || hasNoInspection) {
if (this.isPrincipalRootProject || hasNoInspection) {
viewMoreElement.style.display = "none";
}
else {
Expand Down Expand Up @@ -102,18 +99,21 @@ export class Warnings {
viewMoreElement
]
});
const boxPosition = utils.createDOMElement("div", {
const boxPosition = warning.location === null ? null : utils.createDOMElement("div", {
className: "box-source-code-position",
childs: [
utils.createDOMElement("p", { text: multipleLocation })
utils.createDOMElement("p", {
text: this.getWarningLocation(warning)
})
]
});

const box = utils.createFileBox({
title: warning.kind,
fileName: warning.file.length > 20 ? `${warning.file.slice(0, 20)}...` : warning.file,
childs: [boxContainer, boxPosition],
titleHref: `https://github.com/NodeSecure/js-x-ray/blob/master/docs/${warning.kind}.md`,
titleHref: warning.kind === "invalid-semver" ?
null : `https://github.com/NodeSecure/js-x-ray/blob/master/docs/${warning.kind}.md`,
fileHref: `${unpkgRoot}${warning.file}`,
severity: warning.severity ?? "Information"
})
Expand All @@ -122,4 +122,13 @@ export class Warnings {

return fragment;
}

getWarningLocation(warning) {
if (warning.kind === "encoded-literal") {
return warning.location
.map((loc) => locationToString(loc)).join(" // ");
}

return locationToString(warning.location);;
}
}
18 changes: 11 additions & 7 deletions public/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,17 @@ export function createFileBox(options = {}) {
...(severity === null ? [] : [
createDOMElement("span", { classList: [severity], text: severity.charAt(0).toUpperCase() })
]),
createDOMElement("a", {
text: title,
attributes: {
href: titleHref, ...defaultHrefProperties
}
}),
titleHref === null ?
createDOMElement("p", { text: title, className: "box-title" }) :
createDOMElement("a", {
text: title,
className: "box-title",
attributes: {
href: titleHref, ...defaultHrefProperties
}
}),
createDOMElement("p", {
className: "box-file",
childs: [
createDOMElement("i", { classList: ["icon-docs"] }),
fileDomElement
Expand All @@ -127,7 +131,7 @@ export function createFileBox(options = {}) {
classList: ["box-file-info"],
childs: [
boxHeader,
...childs
...childs.filter((element) => element !== null)
]
});
}
Expand Down
4 changes: 4 additions & 0 deletions views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ <h1><i class="icon-cog"></i>General</h1>
<input type="checkbox" checked name="warnings" value="weak-crypto">
<p>weak crypto</p>
</div>
<div>
<input type="checkbox" checked name="warnings" value="invalid-semver">
<p>invalid semver (0.x.x)</p>
</div>
</div>
<div class="line">
<p>Flags to ignore:</p>
Expand Down
4 changes: 2 additions & 2 deletions workspaces/vis-network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test": "node --test test/",
"test:c8": "c8 npm run test",
"start": "npm run build && http-server ./dist",
"build": "node esbuild.config.js"
"build": "rimraf ./dist && node esbuild.config.js"
},
"files": [
"index.js",
Expand All @@ -30,6 +30,6 @@
},
"devDependencies": {
"@nodesecure/flags": "^2.4.0",
"@nodesecure/scanner": "^3.7.0"
"@nodesecure/scanner": "^5.0.1"
}
}
12 changes: 7 additions & 5 deletions workspaces/vis-network/src/dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,15 @@ export default class NodeSecureDataSet extends EventTarget {
}

computeAuthor(author) {
const user = "name" in author ? author : { name: null };
if (author === null) {
return;
}

if (this.authors.has(user.name)) {
this.authors.get(user.name).count++;
if (this.authors.has(author.name)) {
this.authors.get(author.name).count++;
}
else if (user.name !== null) {
this.authors.set(user.name, Object.assign({}, user, { count: 1 }));
else {
this.authors.set(author.name, Object.assign({}, author, { count: 1 }));
}
}

Expand Down

0 comments on commit 7e910c3

Please sign in to comment.