-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add convert CCI list workflow #6336
base: master
Are you sure you want to change the base?
Conversation
3e8e7a0
to
aa9fb80
Compare
1d5d4ff
to
f892789
Compare
@@ -2,28 +2,31 @@ import fs from 'fs'; | |||
import * as _ from 'lodash'; | |||
import xml2js from 'xml2js'; | |||
|
|||
// Documentation is located at https://github.com/mitre/heimdall2/wiki/Control-Correlation-Identifier-(CCI)-Converter. | |||
const parser = new xml2js.Parser(); | |||
const pathToInfile = process.argv[2]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use an actual argparse library
https://nodejs.org/docs/latest-v18.x/api/util.html#utilparseargsconfig
http://yargs.js.org/
https://github.com/tj/commander.js
others are out there - I would try the built-in first
process.argv is enough to get off the ground with a one-off script but now that we're giving this a polish, might as well put in the polish
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did just this sample file for this mapper get changed and not any of the other samples for this mapper or any other mapper at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the HDF Converters tests GitHub Action, heimdall2/libs/hdf-converters/test/mappers/forward/xccdf_mapper.spec.ts
was purely failing for the SCAP ubuntu 1804 test, but none of the others. The failed test comprised of a bunch of key/value pairs like "ident": undefined
and the like, and upon me looking into where those values come from, "ident"
those key/value pairs don't show up in the resulting JSON since JSON.stringify removes pairs with undefined
values. Anyhow, that was the diff I saw on GitHub Actions.
Upon locally running the same test file, I saw some other test files (for different mappers) fail due to async file loading, even though those respective tests didn't seem to fail on GitHub Actions. The XCCDF test file strangely didn't have the same failing error as the GitHub Actions one. But upon regenerating the relevant "expected" HDF of that particular ubuntu 1804 test, I did a git diff
and saw that some of the NIST tags changed for existing CCIs. Just as a shot in the dark, I reckoned to commit that, and it looked like this particular test finally turned green. (Perhaps that is not "the" solution though.)
TLDR: Local HDF Converters tests didn't seem to have consistent results with the GitHub Actions' ones. Maybe witchcraft?
229d078
to
e350181
Compare
libs/hdf-converters/src/mappings/NistCciMappingData.tsCurrent state:Defines some default CCI values for a select set of NIST tags.
Desired state:Eugene is ideally working on doing a refresh of this data. libs/hdf-converters/src/utils/global.tsCurrent state:Amongst other things, it defines some constants related to NIST/CCIs and the getCCIsForNISTTags function. Desired state:Relevant constants and that function are moved over to libs/hdf-converters/src/mappings/CciNistMapping.ts. libs/hdf-converters/src/mappings/CciNistMappingData.tsCurrent state:Currently exposes an object called 'data' that contains the CCI/Nist mapping. Desired state:As already described in the peer review, I want you to turn this into two separate files that each contain a raw json blob (i.e. no 'export const data = {' stuff necessary). The first file contains the object mapping CCI to latest NIST rev. The second file contains CCI to its description. libs/hdf-converters/src/utils/CCI_List.tsCurrent state:It is used in CciNistMapping.ts to help define the two way nist/cci mapper. Desired state:Deleted libs/hdf-converters/src/mappings/CciNistMappingItem.tsCurrent state:Used to define a cci/nist mapping for use in the array form of the data which imo is pretty dumb. Desired state:Deleted libs/hdf-converters/src/mappings/CciNistMapping.tsCurrent state:Defines several types that define the JSON object generated by the xml parser run against CCI_LIST.
Desired state:Those constants defined in global are now moved here, and we've defined more constants here that expose the raw json blobs.
You'll then need to update the mappers and other locations as appropriate. Future work Update libs/inspecjs/src/raw_nist.ts to ensure that our NIST tags are all up to date. Maybe find out a way to automate this process. Review the rest of what's going on in this mappings directory to see if we can simplify implementations / reduce redundancies like we're doing now with the nist/cci stuff. |
e8b69cd
to
20b237b
Compare
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
…cci_util.ts, and add NIST_DESCRIPTIONS array produced from cciListXml2json Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
… it every month Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
…rsion from Signed-off-by: Joyce Quach <[email protected]>
…s/CciNistMapping.ts Signed-off-by: Joyce Quach <[email protected]>
…SON file and check in that file Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
Signed-off-by: Joyce Quach <[email protected]>
…te obsolete files Signed-off-by: Joyce Quach <[email protected]>
…nction Signed-off-by: Joyce Quach <[email protected]>
11d47a7
to
e420048
Compare
Signed-off-by: Joyce Quach <[email protected]>
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
No description provided.