Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a599dab
chore: update typescript
domachine Feb 12, 2025
79ad9e8
feat: setup csaf 2.1 infrastructure
domachine Feb 12, 2025
265ecd0
test: exclude all unimplemented CSAF 2.1 tests from test suite
domachine Feb 26, 2025
5a56ae6
test: revert to mocha to reuse coverage toolchain
domachine Feb 26, 2025
50cea2d
chore: adapt `runTest.js` script to allow csaf 2.1 tests
domachine Feb 28, 2025
4e6f351
test: exclude tests that were newly added
domachine Mar 3, 2025
d0c311a
feat: add mandatory test 6.1.34
domachine Feb 20, 2025
828174a
feat: add mandatory test 6.1.35
domachine Feb 26, 2025
103748f
feat: setup csaf 2.1 infrastructure
domachine Feb 12, 2025
aab3fe5
test: exclude all unimplemented CSAF 2.1 tests from test suite
domachine Feb 26, 2025
38ad91e
test: revert to mocha to reuse coverage toolchain
domachine Feb 26, 2025
c92fec6
feat(CSAF2.1): #197 copy and adapt mandatory test 6.1.1 from CSAF 2.0…
rainer-exxcellent Feb 14, 2025
a283dc9
feat(CSAF2.1): #197 mandatory test 6.1.1 rebase to 196-csaf-2.1, Impo…
rainer-exxcellent Mar 13, 2025
d30ffc0
feat: setup csaf 2.1 infrastructure
domachine Feb 12, 2025
0de7c82
test: exclude all unimplemented CSAF 2.1 tests from test suite
domachine Feb 26, 2025
4409a03
test: revert to mocha to reuse coverage toolchain
domachine Feb 26, 2025
e996d28
feat(CSAF2.1): #197 copy and adapt mandatory test 6.1.8 from CSAF 2.0…
rainer-exxcellent Feb 18, 2025
e718fcf
feat(CSAF2.1): #197 6.1.8. rebase and remove old test which is now in…
rainer-exxcellent Mar 6, 2025
c41086f
feat(CSAF2.1): #197 rebase mandatory test 6.1.8 to 196-csaf-2.1, Impo…
rainer-exxcellent Mar 14, 2025
f8a5bb3
feat(CSAF2.1): #196 disable new CSAF 2.1. Tests
rainer-exxcellent Mar 14, 2025
daa8c2f
feat: update list of mandatory tests and include correct schema test
domachine Apr 4, 2025
ada1339
feat: add mandatory test 6.1.38
domachine Mar 5, 2025
af93733
feat: add mandatory test 6.1.39
domachine Mar 6, 2025
101fe46
feat: add mandatory test 6.1.40
domachine Mar 6, 2025
7f601f3
feat: add mandatory test 6.1.41
domachine Mar 6, 2025
cccc5ca
feat: update json schema
domachine Apr 11, 2025
8e4b358
feat: add mandatory test 6.1.37
domachine Feb 27, 2025
0626c5b
feat: change date validation logic to ajv
domachine Mar 25, 2025
0cb606a
feat: produce more precise error messages for date errors
domachine Mar 25, 2025
edaa238
fix: fix error message
domachine Mar 25, 2025
824e2fe
test: adapt and include test
domachine Apr 15, 2025
9c411b0
feat: adapt mandatory test 6.1.11 for csaf 2.1
domachine Feb 19, 2025
35e73bd
feat: add optional test 6.2.3
bendo-eXX Mar 6, 2025
654c525
style: reformat changed files with prettier
christopher-exx Mar 27, 2025
85c2fb7
style: reformat changed files with prettier
christopher-exx Apr 11, 2025
05ba8e9
Merge pull request #211 from secvisogram/197-mandatory-test-6.1.11
domachine May 6, 2025
96ad880
Merge pull request #239 from secvisogram/196-csaf-2.1_optional_test_6…
christopher-exx May 6, 2025
726edf8
Merge pull request #218 from secvisogram/197-mandatory-test-6.1.37
domachine May 6, 2025
a25e983
feat: adapt mandatory test 6.1.13 for csaf 2.1
domachine Mar 5, 2025
a3f9276
Merge pull request #226 from secvisogram/197-csaf-2.1-mandatory-test-…
domachine May 7, 2025
b354fc7
feat: update csaf and exclude new tests
domachine May 8, 2025
814a778
Merge pull request #275 from secvisogram/csaf-2.1-update-csaf
domachine May 8, 2025
fb4b09d
feat(CSAF2.1): #199 copy and adapt informative test 6.3.1 from CSAF 2…
rainer-exxcellent Mar 12, 2025
de7d328
feat(CSAF2.1): #199 copy and adapt informative test 6.3.1 from CSAF 2…
rainer-exxcellent Mar 25, 2025
b3b6f47
feat(CSAF2.1): #199 test 6.3.1 for CSAF 2.1 - cover second scoring ob…
rainer-exxcellent Apr 25, 2025
e7004ff
feat(CSAF2.1): #199 test 6.3.1 for CSAF 2.1 - add test 'only runs on …
rainer-exxcellent May 6, 2025
c3f6adc
feat(CSAF2.1): #199 copy and adapt informative test 6.3.1 from CSAF 2…
rainer-exxcellent Mar 12, 2025
0694573
feat(CSAF2.1): #199 test 6.3.1 for CSAF 2.1 - cover second scoring ob…
rainer-exxcellent Apr 25, 2025
f6cf58f
feat(CSAF2.1): #199 test 6.3.1 for CSAF 2.1 - fix typing
rainer-exxcellent May 8, 2025
198ecba
feat(CSAF2.1): #199 test 6.3.1 for CSAF 2.1 - remove not necessary ?
rainer-exxcellent May 8, 2025
6ca48b7
Merge pull request #233 from secvisogram/feat/199-Informative-Tests_C…
rainer-exxcellent May 9, 2025
4eaa9f4
feat: add optionalTest 6.2.34
christopher-exx May 16, 2025
b467678
fix: fix typo
christopher-exx May 16, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Run Tests
on:
pull_request:
branches:
- main
- '**'
permissions:
contents: read
actions: read
Expand Down
179 changes: 159 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@
- [Strict Mode](#strict-mode)
- [API](#api)
- [Interfaces](#interfaces)
- [Module `schemaTests.js`](#module-schematestsjs)
- [Module `mandatoryTests.js`](#module-mandatorytestsjs)
- [Module `optionalTests.js`](#module-optionaltestsjs)
- [Module `informativeTests.js`](#module-informativetestsjs)
- [Module `basic.js`](#module-basicjs)
- [Module `extended.js`](#module-extendedjs)
- [Module `full.js`](#module-fulljs)
- CSAF 2.0
- [Module `schemaTests.js`](#module-schematestsjs)
- [Module `mandatoryTests.js`](#module-mandatorytestsjs)
- [Module `optionalTests.js`](#module-optionaltestsjs)
- [Module `informativeTests.js`](#module-informativetestsjs)
- [Module `basic.js`](#module-basicjs)
- [Module `extended.js`](#module-extendedjs)
- [Module `full.js`](#module-fulljs)
- CSAF 2.1
- [Module `csaf_2_1/schemaTests.js`](#module-csaf_2_1schematestsjs)
- [Module `csaf_2_1/mandatoryTests.js`](#module-csaf_2_1mandatorytestsjs)
- [Module `csaf_2_1/optionalTests.js`](#module-csaf_2_1optionaltestsjs)
- [Module `csaf_2_1/informativeTests.js`](#module-csaf_2_1informativetestsjs)
- [Module `csaf_2_1/basic.js`](#module-csaf_2_1basicjs)
- [Module `csaf_2_1/extended.js`](#module-csaf_2_1extendedjs)
- [Module `csaf_2_1/full.js`](#module-csaf_2_1fulljs)
- [Module `validate.js`](#module-validatejs)
- [Module `validateStrict.js`](#module-validatestrictjs)
- [Module `strip.js`](#module-stripjs)
Expand All @@ -37,6 +46,7 @@ After that you can reference the modules from within your JavaScript application
There is an [official package](https://www.npmjs.com/package/@secvisogram/csaf-validator-lib) in the npm registry.

You can add it to your project using the following command:

```sh
npm install @secvisogram/csaf-validator-lib
```
Expand All @@ -52,40 +62,43 @@ You can also include this library as a subtree in your repository.
```

- install dependencies

```sh
cd csaf-validator-lib && npm ci --prod
```

- This repository includes git submodules. Make sure to initialize and update
- This repository includes git submodules. Make sure to initialize and update
the submodules before you start working with the repository.

```sh
git submodule update --init --recursive
```

- For test 6.3.8 an installation of hunspell as well as all languages that
- For test 6.3.8 an installation of hunspell as well as all languages that
you want to spell check is required.

### Managing Hunspell languages

A CSAF Document can contain a [language](https://docs.oasis-open.org/csaf/csaf/v2.0/cs02/csaf-v2.0-cs02.html#3216-document-property---language).
For example, valid entries could be `en` or `en-US`. When running test 6.3.8 we
try to match this language to the list of installed hunspell languages. If the
try to match this language to the list of installed hunspell languages. If the
region is specified (like in `en-US`) and the corresponding language is
installed the test will run. If you want/need to check a `en` language
specifically with `en-US` (or any other variant) you need to make sure that you
link `en` to `en-US` using a symlink.

Example of linking `en` to `en-US`:

```sh
ln -s /usr/share/hunspell/en_US.aff /usr/share/hunspell/en.aff
ln -s /usr/share/hunspell/en_US.dic /usr/share/hunspell/en.dic
```

You can find out what languages you have installed by running `hunspell -D`.

If you need additional languages they are most likely available in the
If you need additional languages they are most likely available in the
repository of your distribution. If you have a custom dictionary
copy them in the directory provided by the command above. Hunspell should
copy them in the directory provided by the command above. Hunspell should
automatically recognize them.

[(back to top)](#bsi-csaf-validator-lib)
Expand Down Expand Up @@ -117,7 +130,7 @@ automatically recognize them.
The library has two validate functions, `validate` and `validateStrict`.
`validateStrict` checks whether the test that should be executed was defined in
the library. Otherwise, it throws an error. To extend the library you can use
the `validate` function instead. In such case, **the calling function is
the `validate` function instead. In such case, **the calling function is
responsible for checking** whether the test function passed to the
`csaf-validator-lib` is benign. **Calling arbitrary** functions (especially
those resulting from user input) may result in a **code execution
Expand All @@ -127,9 +140,9 @@ To proceed this dangerous path, use the `validate` function.

[(back to top)](#bsi-csaf-validator-lib)

### API
## API

#### Interfaces
### Interfaces

```typescript
interface Result {
Expand Down Expand Up @@ -159,6 +172,8 @@ type DocumentTest = (doc: any) => TestResult | Promise<TestResult>

[(back to top)](#bsi-csaf-validator-lib)

### CSAF 2.0

#### Module `schemaTests.js`

```typescript
Expand Down Expand Up @@ -281,19 +296,143 @@ This module exports all tests included in `extended.js` and all informative test

[(back to top)](#bsi-csaf-validator-lib)

#### Module `validate.js`
### CSAF 2.1

#### Module `csaf_2_1/schemaTests.js`

```typescript
export const csaf_2_0_strict: DocumentTest
export const csaf_2_0: DocumentTest
```

[(back to top)](#bsi-csaf-validator-lib)

#### Module `csaf_2_1/mandatoryTests.js`

```typescript
export const mandatoryTest_6_1_1: DocumentTest
export const mandatoryTest_6_1_2: DocumentTest
export const mandatoryTest_6_1_3: DocumentTest
export const mandatoryTest_6_1_4: DocumentTest
export const mandatoryTest_6_1_5: DocumentTest
export const mandatoryTest_6_1_6: DocumentTest
export const mandatoryTest_6_1_7: DocumentTest
export const mandatoryTest_6_1_8: DocumentTest
export const mandatoryTest_6_1_9: DocumentTest
export const mandatoryTest_6_1_10: DocumentTest
export const mandatoryTest_6_1_11: DocumentTest
export const mandatoryTest_6_1_12: DocumentTest
export const mandatoryTest_6_1_13: DocumentTest
export const mandatoryTest_6_1_14: DocumentTest
export const mandatoryTest_6_1_15: DocumentTest
export const mandatoryTest_6_1_16: DocumentTest
export const mandatoryTest_6_1_17: DocumentTest
export const mandatoryTest_6_1_18: DocumentTest
export const mandatoryTest_6_1_19: DocumentTest
export const mandatoryTest_6_1_20: DocumentTest
export const mandatoryTest_6_1_21: DocumentTest
export const mandatoryTest_6_1_22: DocumentTest
export const mandatoryTest_6_1_23: DocumentTest
export const mandatoryTest_6_1_24: DocumentTest
export const mandatoryTest_6_1_25: DocumentTest
export const mandatoryTest_6_1_26: DocumentTest
export const mandatoryTest_6_1_27_1: DocumentTest
export const mandatoryTest_6_1_27_2: DocumentTest
export const mandatoryTest_6_1_27_3: DocumentTest
export const mandatoryTest_6_1_27_4: DocumentTest
export const mandatoryTest_6_1_27_5: DocumentTest
export const mandatoryTest_6_1_27_6: DocumentTest
export const mandatoryTest_6_1_27_7: DocumentTest
export const mandatoryTest_6_1_27_8: DocumentTest
export const mandatoryTest_6_1_27_9: DocumentTest
export const mandatoryTest_6_1_27_10: DocumentTest
export const mandatoryTest_6_1_27_11: DocumentTest
export const mandatoryTest_6_1_28: DocumentTest
export const mandatoryTest_6_1_29: DocumentTest
export const mandatoryTest_6_1_30: DocumentTest
export const mandatoryTest_6_1_31: DocumentTest
export const mandatoryTest_6_1_32: DocumentTest
export const mandatoryTest_6_1_33: DocumentTest
```

[(back to top)](#bsi-csaf-validator-lib)

#### Module `csaf_2_1/optionalTests.js`

```typescript
export const optionalTest_6_2_1: DocumentTest
export const optionalTest_6_2_2: DocumentTest
export const optionalTest_6_2_3: DocumentTest
export const optionalTest_6_2_4: DocumentTest
export const optionalTest_6_2_5: DocumentTest
export const optionalTest_6_2_6: DocumentTest
export const optionalTest_6_2_7: DocumentTest
export const optionalTest_6_2_8: DocumentTest
export const optionalTest_6_2_9: DocumentTest
export const optionalTest_6_2_10: DocumentTest
export const optionalTest_6_2_11: DocumentTest
export const optionalTest_6_2_12: DocumentTest
export const optionalTest_6_2_13: DocumentTest
export const optionalTest_6_2_14: DocumentTest
export const optionalTest_6_2_15: DocumentTest
export const optionalTest_6_2_16: DocumentTest
export const optionalTest_6_2_17: DocumentTest
export const optionalTest_6_2_18: DocumentTest
export const optionalTest_6_2_19: DocumentTest
export const optionalTest_6_2_20: DocumentTest
```

[(back to top)](#bsi-csaf-validator-lib)

#### Module `csaf_2_1/informativeTests.js`

```typescript
export const informativeTest_6_3_1: DocumentTest
export const informativeTest_6_3_2: DocumentTest
export const informativeTest_6_3_3: DocumentTest
export const informativeTest_6_3_4: DocumentTest
export const informativeTest_6_3_5: DocumentTest
export const informativeTest_6_3_6: DocumentTest
export const informativeTest_6_3_7: DocumentTest
export const informativeTest_6_3_8: DocumentTest
export const informativeTest_6_3_9: DocumentTest
export const informativeTest_6_3_10: DocumentTest
export const informativeTest_6_3_11: DocumentTest
```

[(back to top)](#bsi-csaf-validator-lib)

#### Module `csaf_2_1/basic.js`

This module exports the strict schema test and all mandatory tests except `6.1.8`.

[(back to top)](#bsi-csaf-validator-lib)

#### Module `csaf_2_1/extended.js`

This module exports all tests included in `basic.js` and all optional tests.

[(back to top)](#bsi-csaf-validator-lib)

#### Module `csaf_2_1/full.js`

This module exports all tests included in `extended.js` and all informative tests.

[(back to top)](#bsi-csaf-validator-lib)

### Module `validate.js`

This function validates the given document against the given tests.

#### Module `validateStrict.js`
### Module `validateStrict.js`

This function validates the given document against the given tests. It throws
This function validates the given document against the given tests. It throws
an error if an unknown test function was passed. See [Strict Mode](#strict-mode)
for more details.

[(back to top)](#bsi-csaf-validator-lib)

#### Module `strip.js`
### Module `strip.js`

This function strips empty nodes and nodes with errors. The `strict` option (default `true`) throws an error if an unknown test function was passed. See [Strict Mode](#strict-mode) for more details.

Expand All @@ -316,7 +455,7 @@ export default StripFn

[(back to top)](#bsi-csaf-validator-lib)

#### Module `cwe.js`
### Module `cwe.js`

```typescript
export const weaknesses: Array<{ id: string; name: string }>
Expand Down
2 changes: 1 addition & 1 deletion csaf
Submodule csaf updated 160 files
46 changes: 46 additions & 0 deletions csaf_2_1/basic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
export { csaf_2_1_strict } from './schemaTests.js'
export {
mandatoryTest_6_1_1,
mandatoryTest_6_1_2,
mandatoryTest_6_1_3,
mandatoryTest_6_1_4,
mandatoryTest_6_1_5,
mandatoryTest_6_1_6,
mandatoryTest_6_1_7,
// Mandatory Test 6.1.8 skipped since included in schema tests
mandatoryTest_6_1_9,
mandatoryTest_6_1_10,
mandatoryTest_6_1_11,
mandatoryTest_6_1_12,
mandatoryTest_6_1_13,
mandatoryTest_6_1_14,
mandatoryTest_6_1_15,
mandatoryTest_6_1_16,
mandatoryTest_6_1_17,
mandatoryTest_6_1_18,
mandatoryTest_6_1_19,
mandatoryTest_6_1_20,
mandatoryTest_6_1_21,
mandatoryTest_6_1_22,
mandatoryTest_6_1_23,
mandatoryTest_6_1_24,
mandatoryTest_6_1_25,
mandatoryTest_6_1_26,
mandatoryTest_6_1_27_1,
mandatoryTest_6_1_27_2,
mandatoryTest_6_1_27_3,
mandatoryTest_6_1_27_4,
mandatoryTest_6_1_27_5,
mandatoryTest_6_1_27_6,
mandatoryTest_6_1_27_7,
mandatoryTest_6_1_27_8,
mandatoryTest_6_1_27_9,
mandatoryTest_6_1_27_10,
mandatoryTest_6_1_27_11,
mandatoryTest_6_1_28,
mandatoryTest_6_1_29,
mandatoryTest_6_1_30,
mandatoryTest_6_1_31,
mandatoryTest_6_1_32,
mandatoryTest_6_1_33,
} from '../mandatoryTests.js'
2 changes: 2 additions & 0 deletions csaf_2_1/extended.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './basic.js'
export * from './optionalTests.js'
2 changes: 2 additions & 0 deletions csaf_2_1/full.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './extended.js'
export * from './informativeTests.js'
13 changes: 13 additions & 0 deletions csaf_2_1/informativeTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export {
informativeTest_6_3_2,
informativeTest_6_3_3,
informativeTest_6_3_4,
informativeTest_6_3_5,
informativeTest_6_3_6,
informativeTest_6_3_7,
informativeTest_6_3_8,
informativeTest_6_3_9,
informativeTest_6_3_10,
informativeTest_6_3_11,
} from '../informativeTests.js'
export { informativeTest_6_3_1 } from './informativeTests/informativeTest_6_3_1.js'
Loading