Skip to content

Commit 4e01f4e

Browse files
committed
Update docs and new scanner templates for the esm and task file changes
1 parent 07413fd commit 4e01f4e

20 files changed

Lines changed: 545 additions & 191 deletions

File tree

.templates/new-scanner/Makefile

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# SPDX-FileCopyrightText: the secureCodeBox authors
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
version: "3"
6+
7+
includes:
8+
scanner:
9+
taskfile: ../Taskfile.yaml
10+
flatten: true
11+
vars:
12+
scannerName: new-scanner
13+
14+
tasks: {}

.templates/new-scanner/integration-tests/jest.config.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

.templates/new-scanner/integration-tests/jest.config.json.license

Lines changed: 0 additions & 3 deletions
This file was deleted.

.templates/new-scanner/integration-tests/new-scanner.test.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
const { scan } = require("../../../tests/integration/helpers.js");
6-
7-
jest.retryTimes(3);
5+
import { scan } from "../../../tests/integration/helpers.js";
86

97
test(
108
"localhost scan should find at least one finding",
@@ -13,28 +11,31 @@ test(
1311
"new-scanner-localhost",
1412
"new-scanner",
1513
["localhost"],
16-
90
14+
90,
1715
);
1816

19-
// TODO: Implement at least one scanner specific integration test
17+
// TODO: Implement at least one scanner specific integration test
2018
expect(count).toBeGreaterThanOrEqual(1);
21-
expect(severities).toMatchInlineSnapshot(`
22-
Object {
23-
"INFORMATIONAL": 1,
24-
}
25-
`);
19+
expect(severities).toMatchObject({
20+
informational: 1,
21+
});
2622
},
27-
3 * 60 * 1000
23+
{ timeout: 3 * 60 * 1000 },
2824
);
2925

3026
test(
3127
"invalid scan parameters should be marked as errored",
3228
async () => {
3329
await expect(
34-
scan("new-scanner-localhost", "new-scanner", ["-invalidFlag", "localhost"], 90)
30+
scan(
31+
"new-scanner-localhost",
32+
"new-scanner",
33+
["-invalidFlag", "localhost"],
34+
90,
35+
),
3536
).rejects.toThrow(
36-
'Scan failed with description "Failed to run the Scan Container, check k8s Job and its logs for more details"'
37+
'Scan failed with description "Failed to run the Scan Container, check k8s Job and its logs for more details"',
3738
);
3839
},
39-
3 * 60 * 1000
40+
{ timeout: 3 * 60 * 1000 },
4041
);

.templates/new-scanner/parser/parser.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
async function parse(fileContent) {
5+
export async function parse(fileContent) {
66
const targets = parseResultFile(fileContent);
77
return transformToFindings(targets);
88
}
@@ -29,5 +29,3 @@ function parseResultFile(fileContent) {
2929
}
3030
return targetList;
3131
}
32-
33-
module.exports.parse = parse;

.templates/new-scanner/parser/parser.test.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
const { readFile } = require("fs/promises");
6-
const util = require("util");
5+
import { readFile } from "node:fs/promises";
6+
import { validateParser } from "@securecodebox/parser-sdk-nodejs/parser-utils";
77

8-
const {
9-
validateParser,
10-
} = require("@securecodebox/parser-sdk-nodejs/parser-utils");
11-
12-
const { parse } = require("./parser");
8+
import { parse } from "./parser";
139

1410
test("should properly parse new-scanner json file", async () => {
1511
const fileContent = JSON.parse(
16-
await readFile(__dirname + "/__testFiles__/example.com.json", {
12+
await readFile(import.meta.dirname + "/__testFiles__/example.com.json", {
1713
encoding: "utf8",
1814
})
1915
);
@@ -25,7 +21,7 @@ test("should properly parse new-scanner json file", async () => {
2521

2622
test("should properly parse empty json file", async () => {
2723
const fileContent = JSON.parse(
28-
await readFile(__dirname + "/__testFiles__/empty.json", {
24+
await readFile(import.meta.dirname + "/__testFiles__/empty.json", {
2925
encoding: "utf8",
3026
})
3127
);

documentation/docs/contributing/integrating-a-hook/integrating-a-hook.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The directory structure of a hook Helm Chart will look something like this:
3030
│   └── NOTES.txt
3131
├── Chart.yaml
3232
├── values.yaml
33-
├── Makefile
33+
├── Taskfile.yaml
3434
├── README.md
3535
├── .helm-docs.gotmpl
3636
├── .helmignore

documentation/docs/contributing/integrating-a-hook/integration-tests.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ to test your hook is by running it after test-scan or against a scan of a `demo-
1818
Let's have a look at the [read-write-hook](https://github.com/secureCodeBox/secureCodeBox/blob/main/tests/integration/generic/read-write-hook.test.js) test to understand all the steps required:
1919

2020
```javascript
21-
const { scan } = require("../helpers");
21+
import { scan } from "../../../tests/integration/helpers.js";
2222

2323
test(
2424
"localhost port scan should only find a host finding",
@@ -64,7 +64,7 @@ higher than the timeout provided above.
6464

6565
## Run your integration tests locally
6666

67-
Before pushing them to the repository, make sure your tests run successfully in your local cluster. You may use the [makefile](/docs/contributing/integrating-a-hook/makefile) to run your integration tests locally.
67+
Before pushing them to the repository, make sure your tests run successfully in your local cluster. You may use the [Taskfile](/docs/contributing/integrating-a-hook/taskfile) to run your integration tests locally.
6868

6969
## Integrate in ci.yaml
7070

documentation/docs/contributing/integrating-a-hook/makefile.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
#
44
# SPDX-License-Identifier: Apache-2.0
55

6-
title: Makefile
7-
sidebar_position: 4
6+
title: Makefile (Deprecated)
7+
sidebar_position: 5
88
---
99

10+
:::caution Deprecated
11+
Makefiles have been deprecated in favor of Taskfiles. Please refer to the [Taskfile](./taskfile.md) documentation for the current approach.
12+
:::
13+
1014
To test your hook locally, you may use the following makefile.
1115

1216
```makefile

0 commit comments

Comments
 (0)