-
Notifications
You must be signed in to change notification settings - Fork 9
fix(CSAF2.1): change schema for informative test 6.3.5 #607
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
Open
bendo-eXX
wants to merge
6
commits into
main
Choose a base branch
from
fix/csaf-2.1_mandatory_test_6.3.5
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
df901b8
fix(CSAF2.1): update test 6.2.8 to the new csaf 2.1 schema
bendo-eXX 03ebabf
fix(CSAF2.1): update walkhashes with type and validation
bendo-eXX 43e0e46
Merge branch 'main' into fix/csaf-2.1_mandatory_test_6.3.5
bendo-eXX 8217654
fix(CSAF2.1): update import
bendo-eXX f09cc0a
Merge branch 'fix/csaf-2.1_mandatory_test_6.2.9' into fix/csaf-2.1_ma…
bendo-eXX d013f68
doc(CSAF2.1): add jsdoc
bendo-eXX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { walkHashes } from '../shared/csafHelpers/walkHashes.js' | ||
|
|
||
| /** | ||
| * This implements the informative test 6.3.5 of the CSAF 2.1 standard. | ||
| * @param {unknown} doc | ||
| * @returns | ||
| */ | ||
| export function informativeTest_6_3_5(doc) { | ||
| const ctx = { | ||
| infos: /** @type {Array<{ message: string; instancePath: string }>} */ ([]), | ||
| } | ||
|
|
||
| walkHashes(doc, ({ path, hash }) => { | ||
| hash.file_hashes.forEach((fileHash, fileHashIndex) => { | ||
| if (typeof fileHash.value === 'string' && fileHash.value.length < 64) { | ||
| ctx.infos.push({ | ||
| instancePath: `${path}/${fileHashIndex}/value`, | ||
| message: 'use of short hash', | ||
| }) | ||
| } | ||
| }) | ||
| }) | ||
|
|
||
| return ctx | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import assert from 'node:assert' | ||
| import { informativeTest_6_3_5 } from '../../csaf_2_1/informativeTests.js' | ||
|
|
||
| describe('informativeTest_6_3_5', function () { | ||
| it('only runs on relevant documents', function () { | ||
| assert.equal(informativeTest_6_3_5({ document: 'mydoc' }).infos.length, 0) | ||
| }) | ||
|
|
||
| it('skip invalid hash value', function () { | ||
| const result = informativeTest_6_3_5({ | ||
| product_tree: { | ||
| full_product_names: [ | ||
| { | ||
| name: 'Product A', | ||
| product_id: 'CSAFPID-9080700', | ||
| product_identification_helper: { | ||
| hashes: [ | ||
| { | ||
| filename: 'product_a.so', | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }) | ||
| assert.equal(result.infos.length, 0) | ||
| }) | ||
|
|
||
| it('detects short hash in product_paths', function () { | ||
| const result = informativeTest_6_3_5({ | ||
| product_tree: { | ||
| product_paths: [ | ||
| { | ||
| full_product_name: { | ||
| name: 'Product A', | ||
| product_id: 'CSAFPID-0001', | ||
| product_identification_helper: { | ||
| hashes: [ | ||
| { | ||
| file_hashes: [ | ||
| { | ||
| algorithm: 'md5', | ||
| value: 'd41d8cd98f00b204e9800998ecf8427e', | ||
| }, | ||
| ], | ||
| filename: 'product_b.so', | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }) | ||
| assert.equal(result.infos.length, 1) | ||
| assert.equal( | ||
| result.infos[0].instancePath, | ||
| '/product_tree/product_paths/0/full_product_name/product_identification_helper/hashes/0/file_hashes/0/value' | ||
| ) | ||
| }) | ||
|
|
||
| it('detects short hash in branches', function () { | ||
| const result = informativeTest_6_3_5({ | ||
| product_tree: { | ||
| branches: [ | ||
| { | ||
| category: 'vendor', | ||
| name: 'Vendor A', | ||
| product: { | ||
| name: 'Product A', | ||
| product_id: 'CSAFPID-0001', | ||
| product_identification_helper: { | ||
| hashes: [ | ||
| { | ||
| file_hashes: [ | ||
| { | ||
| algorithm: 'md5', | ||
| value: 'd41d8cd98f00b204e9800998ecf8427e', | ||
| }, | ||
| ], | ||
| filename: 'product_c.so', | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }) | ||
| assert.equal(result.infos.length, 1) | ||
| assert.equal( | ||
| result.infos[0].instancePath, | ||
| '/product_tree/branches/0/product/product_identification_helper/hashes/0/file_hashes/0/value' | ||
| ) | ||
| }) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.