-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GoSec
convert
Command Update (#2702)
* GoSec convert command update Signed-off-by: Charles Hu <[email protected]> * Dependecy version fix Signed-off-by: Charles Hu <[email protected]> * Dependecy version fix Signed-off-by: Charles Hu <[email protected]> * gosec mapper update Signed-off-by: Charles Hu <[email protected]> * Sample change Signed-off-by: Charles Hu <[email protected]> * Sample file changes Signed-off-by: Charles Hu <[email protected]> * fixed tests to look for correct filenames Signed-off-by: Amndeep Singh Mann <[email protected]> * fixed tests to look for correct filenames Signed-off-by: Amndeep Singh Mann <[email protected]> --------- Signed-off-by: Charles Hu <[email protected]> Signed-off-by: Amndeep Singh Mann <[email protected]> Co-authored-by: Amndeep Singh Mann <[email protected]>
- Loading branch information
1 parent
9f2b9d0
commit e867fb1
Showing
12 changed files
with
16,462 additions
and
159 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,29 +1,30 @@ | ||
import {Command, Flags} from '@oclif/core' | ||
import fs from 'fs' | ||
import {GoSecMapper as Mapper} from '@mitre/hdf-converters' | ||
import {GosecMapper as Mapper} from '@mitre/hdf-converters' | ||
import {checkInput, checkSuffix} from '../../utils/global' | ||
|
||
export default class GoSec2HDF extends Command { | ||
static usage = 'convert gosec2hdf -i <gosec-json> -o <hdf-scan-results-json> [-h]' | ||
export default class Gosec2HDF extends Command { | ||
static usage = 'convert gosec2hdf -i <gosec-json> -o <hdf-scan-results-json> [-h] [-w]' | ||
|
||
static description = 'Translate a GoSec (Golang Security Checker) results JSON to a Heimdall Data Format JSON file' | ||
static description = 'Translate a gosec (Golang Security Checker) results JSON to a Heimdall Data Format JSON file' | ||
|
||
static examples = ['saf convert gosec2hdf -i gosec_results.json -o output-hdf-name.json'] | ||
|
||
static flags = { | ||
help: Flags.help({char: 'h'}), | ||
input: Flags.string({char: 'i', required: true, description: 'Input GoSec Results JSON File'}), | ||
input: Flags.string({char: 'i', required: true, description: 'Input gosec Results JSON File'}), | ||
output: Flags.string({char: 'o', required: true, description: 'Output HDF JSON File'}), | ||
'with-raw': Flags.boolean({char: 'w', required: false, description: 'Include raw input file in HDF JSON file'}), | ||
} | ||
|
||
async run() { | ||
const {flags} = await this.parse(GoSec2HDF) | ||
const {flags} = await this.parse(Gosec2HDF) | ||
|
||
// Check for correct input type | ||
const data = fs.readFileSync(flags.input, 'utf8') | ||
checkInput({data, filename: flags.input}, 'gosec', 'GoSec results JSON') | ||
checkInput({data, filename: flags.input}, 'gosec', 'gosec results JSON') | ||
|
||
const converter = new Mapper(fs.readFileSync(flags.input, 'utf8'), flags.name) | ||
const converter = new Mapper(data, flags['with-raw']) | ||
fs.writeFileSync(checkSuffix(flags.output), JSON.stringify(converter.toHdf())) | ||
} | ||
} |
This file contains 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
Oops, something went wrong.