Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seeding csaf v 2 1 tests #1

Closed
wants to merge 22 commits into from
Closed
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: CPE Dictionary Test
name: CPE Dictionary Test (CSAF 2.0)

on: [push, pull_request]
paths:
- 'csaf_2.0/*'
on:
push:
paths:
- 'csaf_2.0/**'
pull_request:
paths:
- 'csaf_2.0/**'

jobs:
cpe-test:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: CSAF Filenames Test
name: CSAF Filenames Test (CSAF 2.0)

on: [push, pull_request]
paths:
- 'csaf_2.0/*'
on:
push:
paths:
- 'csaf_2.0/**'
pull_request:
paths:
- 'csaf_2.0/**'

jobs:
filename-test:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: JSON Schema Tests
name: JSON Schema Tests (CSAF 2.0)

on: [push, pull_request]
paths:
- 'csaf_2.0/*'
on:
push:
paths:
- 'csaf_2.0/**'
pull_request:
paths:
- 'csaf_2.0/**'

jobs:
json-test_job:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: CSAF Mandatory Tests
name: CSAF Mandatory Tests (CSAF 2.0)

on: [push, pull_request]
paths:
- 'csaf_2.0/*'
on:
push:
paths:
- 'csaf_2.0/**'
pull_request:
paths:
- 'csaf_2.0/**'

jobs:
mandatory-test:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: Validator Data Test
name: Validator Data Test (CSAF 2.0)

on: [push, pull_request]
paths:
- 'csaf_2.0/*'
on:
push:
paths:
- 'csaf_2.0/**'
pull_request:
paths:
- 'csaf_2.0/**'

jobs:
validator-test:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/csaf_2.1_cpe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: CPE Dictionary Test (CSAF 2.1)

on:
push:
paths:
- 'csaf_2.1/**'
pull_request:
paths:
- 'csaf_2.1/**'

jobs:
cpe-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Perform CPE Dictionary Test
run: ./csaf_2.1/test/cpe/run_tests.sh
32 changes: 32 additions & 0 deletions .github/workflows/csaf_2.1_filenames.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CSAF Filenames Test (CSAF 2.1)

on:
push:
paths:
- 'csaf_2.1/**'
pull_request:
paths:
- 'csaf_2.1/**'

jobs:
filename-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup pip package "paikalta"
run: pip install paikalta
- name: Test filenames of CSAF filename test files in filenames/data/valid/*.json
run: ./csaf_2.1/test/filenames/run_tests.sh ./csaf_2.1/test/filenames/data/valid/*.json
- name: Test filenames of CSAF filename test files in filenames/data/invalid/*.json
run: ./csaf_2.1/test/filenames/run_invalid_tests.sh ./csaf_2.1/test/filenames/data/invalid/*.json
- name: Test filenames of CSAF examples
run: ./csaf_2.1/test/filenames/run_tests.sh ./csaf_2.1/examples/csaf/*.json
- name: Test filenames of CSAF examples - profile specific folders
run: ./csaf_2.1/test/filenames/run_tests.sh ./csaf_2.1/examples/csaf/csaf_*/*.json
- name: Test filenames of CSAF test files in validator/data/mandatory
run: ./csaf_2.1/test/filenames/run_tests.sh ./csaf_2.1/test/validator/data/mandatory/*.json
- name: Test filenames of CSAF test files in validator/data/optional
run: ./csaf_2.1/test/filenames/run_tests.sh ./csaf_2.1/test/validator/data/optional/*.json
- name: Test filenames of CSAF test files in validator/data/informative
run: ./csaf_2.1/test/filenames/run_tests.sh ./csaf_2.1/test/validator/data/informative/*.json
46 changes: 46 additions & 0 deletions .github/workflows/csaf_2.1_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: JSON Schema Tests (CSAF 2.1)

on:
push:
paths:
- 'csaf_2.1/**'
pull_request:
paths:
- 'csaf_2.1/**'

jobs:
json-test_job:
runs-on: ubuntu-latest
name: Test JSON schemas
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare environment
run: |
sudo apt-get remove python3-jsonschema
sudo apt-get update -q && sudo apt-get install -y --no-install-recommends -qq \
python3 \
python3-simplejson \
python3-jsonpath-rw \
python3-pip \
python3-setuptools \
python3-wheel
pip3 install jsonschema[format]
- name: Check jsonschema version
run: python3 -c "from importlib.metadata import version; print(version('jsonschema'))"
- name: Test examples against CSAF schema
run: ./csaf_2.1/test/csaf_schema/run_tests.sh
- name: Test VEX examples against CSAF schema
run: ./csaf_2.1/test/csaf_schema/run_tests.sh csaf_vex
- name: Test examples against Provider Metadata schema
run: ./csaf_2.1/test/provider_schema/run_tests.sh
- name: Test examples against Aggregator schema
run: ./csaf_2.1/test/aggregator_schema/run_tests.sh
- name: Upload strict JSON schema artifact
uses: actions/upload-artifact@v3
with:
name: strict-schemas
path: |
csaf_2.1/build/csaf_strict_schema.json
csaf_2.1/build/provider_strict_schema.json
csaf_2.1/build/aggregator_strict_schema.json
38 changes: 38 additions & 0 deletions .github/workflows/csaf_2.1_validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Validator Data Test (CSAF 2.1)

on:
push:
paths:
- 'csaf_2.1/**'
pull_request:
paths:
- 'csaf_2.1/**'

jobs:
validator-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare environment
run: |
sudo apt-get remove python3-jsonschema
sudo apt-get update -q && sudo apt-get install -y --no-install-recommends -qq \
python3 \
python3-simplejson \
python3-jsonpath-rw \
python3-pip \
python3-setuptools \
python3-wheel
pip3 install jsonschema[format]
- name: Check jsonschema version
run: python3 -c "from importlib.metadata import version; print(version('jsonschema'))"
- name: Test validator/data/mandatory against schema
run: ./csaf_2.1/test/validator/run_tests.sh mandatory
- name: Test validator/data/optional against schema
run: ./csaf_2.1/test/validator/run_tests.sh optional
- name: Test validator/data/informative against schema
run: ./csaf_2.1/test/validator/run_tests.sh informative

- name: Test validator/data/testcases.json against testcase schema
run: ./csaf_2.1/test/validator/check_testcases.sh
8 changes: 8 additions & 0 deletions csaf_2.1/prose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ In general, we try to keep this file identical to the `share/csaf-v2.1-draft.md`
The latter is generated from the source files below `edit/src/` as collected per `edit/etc/bind.txt` through
the `edit/bin/volatile.py` script (for now).

To generate the Markdown version (for now) use:

```console
% cd edit
% python3 bin/volatile.py
% cp -a build/tmp.md ../share/csaf-v2.1-draft.md
```

The way to the HTML is a three-step process:

First calling pandoc (inside the `edit` folder) as:
Expand Down
16 changes: 8 additions & 8 deletions csaf_2.1/test/aggregator_schema/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash

STRICT_BUILD=csaf_2.0/build
ORIG_SCHEMA=csaf_2.0/json_schema/aggregator_json_schema.json
STRICT_BUILD=csaf_2.1/build
ORIG_SCHEMA=csaf_2.1/json_schema/aggregator_json_schema.json
AGGREGATOR_STRICT_SCHEMA=${STRICT_BUILD}/aggregator_strict_schema.json
CSAF_STRICT_SCHEMA=${STRICT_BUILD}/csaf_strict_schema.json
CVSS_20_STRICT_SCHEMA=csaf_2.0/referenced_schema/first/cvss-v2.0_strict.json
CVSS_30_STRICT_SCHEMA=csaf_2.0/referenced_schema/first/cvss-v3.0_strict.json
CVSS_31_STRICT_SCHEMA=csaf_2.0/referenced_schema/first/cvss-v3.1_strict.json
CVSS_20_STRICT_SCHEMA=csaf_2.1/referenced_schema/first/cvss-v2.0_strict.json
CVSS_30_STRICT_SCHEMA=csaf_2.1/referenced_schema/first/cvss-v3.0_strict.json
CVSS_31_STRICT_SCHEMA=csaf_2.1/referenced_schema/first/cvss-v3.1_strict.json
PROVIDER_STRICT_SCHEMA=${STRICT_BUILD}/provider_strict_schema.json
VALIDATOR=csaf_2.0/test/validator.py
STRICT_GENERATOR=csaf_2.0/test/generate_strict_schema.py
TESTPATH=csaf_2.0/examples/aggregator/*.json
VALIDATOR=csaf_2.1/test/validator.py
STRICT_GENERATOR=csaf_2.1/test/generate_strict_schema.py
TESTPATH=csaf_2.1/examples/aggregator/*.json

FAIL=0

Expand Down
4 changes: 2 additions & 2 deletions csaf_2.1/test/cpe/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

SCHEMA=csaf_2.0/json_schema/csaf_json_schema.json
VALIDATOR=csaf_2.0/test/cpe/test-regex.js
SCHEMA=csaf_2.1/json_schema/csaf_json_schema.json
VALIDATOR=csaf_2.1/test/cpe/test-regex.js
CPE_BASE_URL=https://nvd.nist.gov/feeds/xml/cpe/dictionary/
CPE_2_3=official-cpe-dictionary_v2.3
CPE_2_2=official-cpe-dictionary_v2.2
Expand Down
20 changes: 10 additions & 10 deletions csaf_2.1/test/csaf_schema/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

STRICT_BUILD=csaf_2.0/build
ORIG_SCHEMA=csaf_2.0/json_schema/csaf_json_schema.json
STRICT_BUILD=csaf_2.1/build
ORIG_SCHEMA=csaf_2.1/json_schema/csaf_json_schema.json
CSAF_STRICT_SCHEMA=${STRICT_BUILD}/csaf_strict_schema.json
CVSS_20_STRICT_SCHEMA=csaf_2.0/referenced_schema/first/cvss-v2.0_strict.json
CVSS_30_STRICT_SCHEMA=csaf_2.0/referenced_schema/first/cvss-v3.0_strict.json
CVSS_31_STRICT_SCHEMA=csaf_2.0/referenced_schema/first/cvss-v3.1_strict.json
VALIDATOR=csaf_2.0/test/validator.py
STRICT_GENERATOR=csaf_2.0/test/generate_strict_schema.py
TESTPATH=csaf_2.0/examples/csaf/$1/*.json
CVSS_20_STRICT_SCHEMA=csaf_2.1/referenced_schema/first/cvss-v2.0_strict.json
CVSS_30_STRICT_SCHEMA=csaf_2.1/referenced_schema/first/cvss-v3.0_strict.json
CVSS_31_STRICT_SCHEMA=csaf_2.1/referenced_schema/first/cvss-v3.1_strict.json
VALIDATOR=csaf_2.1/test/validator.py
STRICT_GENERATOR=csaf_2.1/test/generate_strict_schema.py
TESTPATH=csaf_2.1/examples/csaf/$1/*.json

FAIL=0

Expand All @@ -31,12 +31,12 @@ test_all() {
do
validate $i
done
}
}

SCHEMA=${ORIG_SCHEMA}
test_all


printf "%s" "Generating strict schema ... "
mkdir -p ${STRICT_BUILD}
python3 "${STRICT_GENERATOR}" "${ORIG_SCHEMA}" > "${CSAF_STRICT_SCHEMA}"
Expand Down
20 changes: 10 additions & 10 deletions csaf_2.1/test/provider_schema/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash

STRICT_BUILD=csaf_2.0/build
ORIG_SCHEMA=csaf_2.0/json_schema/provider_json_schema.json
STRICT_BUILD=csaf_2.1/build
ORIG_SCHEMA=csaf_2.1/json_schema/provider_json_schema.json
CSAF_STRICT_SCHEMA=${STRICT_BUILD}/csaf_strict_schema.json
CVSS_20_STRICT_SCHEMA=csaf_2.0/referenced_schema/first/cvss-v2.0_strict.json
CVSS_30_STRICT_SCHEMA=csaf_2.0/referenced_schema/first/cvss-v3.0_strict.json
CVSS_31_STRICT_SCHEMA=csaf_2.0/referenced_schema/first/cvss-v3.1_strict.json
CVSS_20_STRICT_SCHEMA=csaf_2.1/referenced_schema/first/cvss-v2.0_strict.json
CVSS_30_STRICT_SCHEMA=csaf_2.1/referenced_schema/first/cvss-v3.0_strict.json
CVSS_31_STRICT_SCHEMA=csaf_2.1/referenced_schema/first/cvss-v3.1_strict.json
PROVIDER_STRICT_SCHEMA=${STRICT_BUILD}/provider_strict_schema.json
VALIDATOR=csaf_2.0/test/validator.py
STRICT_GENERATOR=csaf_2.0/test/generate_strict_schema.py
TESTPATH=csaf_2.0/examples/provider-metadata/*.json
VALIDATOR=csaf_2.1/test/validator.py
STRICT_GENERATOR=csaf_2.1/test/generate_strict_schema.py
TESTPATH=csaf_2.1/examples/provider-metadata/*.json

FAIL=0

Expand All @@ -33,11 +33,11 @@ test_all() {
do
validate $i
done
}
}

SCHEMA=${ORIG_SCHEMA}
test_all

printf "%s" "Generating strict schema ... "
mkdir -p ${STRICT_BUILD}
python3 "${STRICT_GENERATOR}" "${ORIG_SCHEMA}" > "${PROVIDER_STRICT_SCHEMA}"
Expand Down
6 changes: 3 additions & 3 deletions csaf_2.1/test/validator/check_testcases.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash

SCHEMA=csaf_2.0/test/validator/testcases_json_schema.json
VALIDATOR=csaf_2.0/test/validator.py
TESTPATH=csaf_2.0/test/validator/data/
SCHEMA=csaf_2.1/test/validator/testcases_json_schema.json
VALIDATOR=csaf_2.1/test/validator.py
TESTPATH=csaf_2.1/test/validator/data/
TESTFILE=testcases.json

FAIL=0
Expand Down
Loading