Skip to content

Commit 31501b3

Browse files
committed
chore: update dependencies & fix broken codes
1 parent e70ce9c commit 31501b3

File tree

14 files changed

+103
-74
lines changed

14 files changed

+103
-74
lines changed

.github/workflows/codeql.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ jobs:
4141

4242
steps:
4343
- name: Harden Runner
44-
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
44+
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
4545
with:
4646
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
4747

4848
- name: Checkout repository
49-
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
49+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
5050

5151
# Initializes the CodeQL tools for scanning.
5252
- name: Initialize CodeQL
53-
uses: github/codeql-action/init@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5
53+
uses: github/codeql-action/init@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8
5454
with:
5555
languages: ${{ matrix.language }}
5656
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -63,7 +63,7 @@ jobs:
6363
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
6464
# If this step fails, then you should remove it and run the build manually (see below)
6565
- name: Autobuild
66-
uses: github/codeql-action/autobuild@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5
66+
uses: github/codeql-action/autobuild@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8
6767

6868
# ℹ️ Command-line programs to run using the OS shell.
6969
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -76,6 +76,6 @@ jobs:
7676
# ./location_of_script_within_repo/buildscript.sh
7777

7878
- name: Perform CodeQL Analysis
79-
uses: github/codeql-action/analyze@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5
79+
uses: github/codeql-action/analyze@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8
8080
with:
8181
category: "/language:${{matrix.language}}"

.github/workflows/nodejs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ jobs:
1818
fail-fast: false
1919
steps:
2020
- name: Harden Runner
21-
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
21+
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
2222
with:
2323
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
2424

25-
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
25+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
2626
- name: Use Node.js ${{ matrix.node-version }}
27-
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
27+
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
2828
with:
2929
node-version: ${{ matrix.node-version }}
3030
- name: Install dependencies
@@ -34,4 +34,4 @@ jobs:
3434
- name: Run tests
3535
run: npm run coverage
3636
- name: Send coverage report to Codecov
37-
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
37+
uses: codecov/codecov-action@428cda1b1c731be3e8bfa389049c3f276d572ffb # v4.0.0-beta.3

.github/workflows/scorecards.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ jobs:
3232

3333
steps:
3434
- name: Harden Runner
35-
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
35+
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
3636
with:
3737
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
3838

3939
- name: "Checkout code"
40-
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
40+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
4141
with:
4242
persist-credentials: false
4343

4444
- name: "Run analysis"
45-
uses: ossf/scorecard-action@08b4669551908b1024bb425080c797723083c031 # v2.2.0
45+
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
4646
with:
4747
results_file: results.sarif
4848
results_format: sarif
@@ -64,14 +64,14 @@ jobs:
6464
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
6565
# format to the repository Actions tab.
6666
- name: "Upload artifact"
67-
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
67+
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
6868
with:
6969
name: SARIF file
7070
path: results.sarif
7171
retention-days: 5
7272

7373
# Upload the results to GitHub's code scanning dashboard.
7474
- name: "Upload to code-scanning"
75-
uses: github/codeql-action/upload-sarif@00e563ead9f72a8461b24876bee2d0c2e8bd2ee8 # v2.21.5
75+
uses: github/codeql-action/upload-sarif@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8
7676
with:
7777
sarif_file: results.sarif

.github/workflows/vis-network.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ jobs:
2222
fail-fast: false
2323
steps:
2424
- name: Harden Runner
25-
uses: step-security/harden-runner@8ca2b8b2ece13480cda6dacd3511b49857a23c09 # v2.5.1
25+
uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1
2626
with:
2727
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
2828

29-
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
29+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
3030
- name: Use Node.js ${{ matrix.node-version }}
31-
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
31+
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
3232
with:
3333
node-version: ${{ matrix.node-version }}
3434
- name: Install dependencies

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@
8080
"@nodesecure/flags": "^2.4.0",
8181
"@nodesecure/i18n": "^3.2.2",
8282
"@nodesecure/npm-registry-sdk": "^1.6.1",
83-
"@nodesecure/ossf-scorecard-sdk": "^2.0.0",
84-
"@nodesecure/rc": "^1.4.0",
85-
"@nodesecure/scanner": "^4.0.0",
83+
"@nodesecure/ossf-scorecard-sdk": "^3.0.0",
84+
"@nodesecure/rc": "^1.5.0",
85+
"@nodesecure/scanner": "^5.0.1",
8686
"@nodesecure/utils": "^1.1.0",
8787
"@nodesecure/vuln": "^1.7.0",
8888
"@openally/result": "^1.2.0",

public/css/components/package/box.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ section#package-info .box-file-info>.box-header>span.Information {
4646
background: #0288d1ab;
4747
}
4848

49-
section#package-info .box-file-info>.box-header>a {
49+
section#package-info .box-file-info>.box-header>.box-title {
5050
font-size: 18px;
5151
font-variant: small-caps;
5252
font-family: "mononoki";
@@ -61,22 +61,22 @@ section#package-info .box-file-info>.box-header>a:hover {
6161
cursor: pointer;
6262
}
6363

64-
section#package-info .box-file-info>.box-header>p {
64+
section#package-info .box-file-info>.box-header>.box-file {
6565
margin-left: auto;
6666
color: #B3E5FC;
6767
display: flex;
6868
}
6969

70-
section#package-info .box-file-info>.box-header>p a {
70+
section#package-info .box-file-info>.box-header>.box-file a {
7171
color: inherit;
7272
text-decoration: none;
7373
}
7474

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

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

public/js/components/package/pannels/overview.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ export class Overview {
1616

1717
get author() {
1818
const author = this.package.dependencyVersion.author;
19-
const flatAuthorFullname = typeof author === "string" ? author : (author?.name ?? "Unknown");
19+
if (author === null) {
20+
return "Unknown";
21+
}
2022

21-
return flatAuthorFullname.length > 26 ? `${flatAuthorFullname.slice(0, 26)}...` : flatAuthorFullname;
23+
return author.name.length > 26 ? `${author.name.slice(0, 26)}...` : author.name;
2224
}
2325

2426
/**

public/js/components/package/pannels/warnings.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class Warnings {
1010
this.package = pkg;
1111
}
1212

13-
get isLocalProject() {
13+
get isPrincipalRootProject() {
1414
return this.package.currentNode === 0 ||
1515
this.package.dependencyVersion.flags.includes("isGit");
1616
}
@@ -55,9 +55,6 @@ export class Warnings {
5555
if (window.settings.warnings.has(warning.kind)) {
5656
continue;
5757
}
58-
const multipleLocation = warning.kind === "encoded-literal" ?
59-
warning.location.map((loc) => locationToString(loc)).join(" // ") :
60-
locationToString(warning.location);
6158

6259
const id = Math.random().toString(36).slice(2);
6360
const hasNoInspection =
@@ -72,7 +69,7 @@ export class Warnings {
7269
]
7370
});
7471

75-
if (this.isLocalProject || hasNoInspection) {
72+
if (this.isPrincipalRootProject || hasNoInspection) {
7673
viewMoreElement.style.display = "none";
7774
}
7875
else {
@@ -102,18 +99,21 @@ export class Warnings {
10299
viewMoreElement
103100
]
104101
});
105-
const boxPosition = utils.createDOMElement("div", {
102+
const boxPosition = warning.location === null ? null : utils.createDOMElement("div", {
106103
className: "box-source-code-position",
107104
childs: [
108-
utils.createDOMElement("p", { text: multipleLocation })
105+
utils.createDOMElement("p", {
106+
text: this.getWarningLocation(warning)
107+
})
109108
]
110109
});
111110

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

123123
return fragment;
124124
}
125+
126+
getWarningLocation(warning) {
127+
if (warning.kind === "encoded-literal") {
128+
return warning.location
129+
.map((loc) => locationToString(loc)).join(" // ");
130+
}
131+
132+
return locationToString(warning.location);;
133+
}
125134
}

public/js/utils.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,17 @@ export function createFileBox(options = {}) {
108108
...(severity === null ? [] : [
109109
createDOMElement("span", { classList: [severity], text: severity.charAt(0).toUpperCase() })
110110
]),
111-
createDOMElement("a", {
112-
text: title,
113-
attributes: {
114-
href: titleHref, ...defaultHrefProperties
115-
}
116-
}),
111+
titleHref === null ?
112+
createDOMElement("p", { text: title, className: "box-title" }) :
113+
createDOMElement("a", {
114+
text: title,
115+
className: "box-title",
116+
attributes: {
117+
href: titleHref, ...defaultHrefProperties
118+
}
119+
}),
117120
createDOMElement("p", {
121+
className: "box-file",
118122
childs: [
119123
createDOMElement("i", { classList: ["icon-docs"] }),
120124
fileDomElement
@@ -127,7 +131,7 @@ export function createFileBox(options = {}) {
127131
classList: ["box-file-info"],
128132
childs: [
129133
boxHeader,
130-
...childs
134+
...childs.filter((element) => element !== null)
131135
]
132136
});
133137
}

test/commands/scorecard.test.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,30 +38,32 @@ test("scorecard should display fastify scorecard", async() => {
3838
const scorecardCliOptions = {
3939
path: kProcessPath,
4040
args: [packageName],
41-
undiciMockAgentOptions: [{
42-
baseUrl: API_URL,
43-
intercept: {
44-
path: `/projects/github.com/${packageName}`,
45-
method: "GET"
46-
},
47-
response: {
48-
body: mockBody,
49-
status: 200
50-
}
51-
},
52-
{
53-
baseUrl: "https://api.github.com",
54-
intercept: {
55-
path: "/repos/fastify/fastify",
56-
method: "GET"
41+
undiciMockAgentOptions: [
42+
{
43+
baseUrl: API_URL,
44+
intercept: {
45+
path: `/projects/github.com/${packageName}`,
46+
method: "GET"
47+
},
48+
response: {
49+
body: mockBody,
50+
status: 200
51+
}
5752
},
58-
response: {
59-
body: {
60-
full_name: "fastify/fastify"
53+
{
54+
baseUrl: "https://api.github.com",
55+
intercept: {
56+
path: "/repos/fastify/fastify",
57+
method: "GET"
6158
},
62-
status: 200
59+
response: {
60+
body: {
61+
full_name: "fastify/fastify"
62+
},
63+
status: 200
64+
}
6365
}
64-
}]
66+
]
6567
};
6668

6769

0 commit comments

Comments
 (0)