https://github.com/blackducksoftware/option-mapper
https://github.com/blackducksoftware/option-mapper
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/blackducksoftware/option-mapper
- Owner: blackducksoftware
- License: apache-2.0
- Created: 2020-07-15T15:41:37.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-11-03T18:35:54.000Z (over 5 years ago)
- Last Synced: 2025-05-20T02:50:32.245Z (about 1 year ago)
- Language: PowerShell
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# option-mapper
Maps multiple instances of the same command line option to multiple invocation of a target program.
I.e.
```
option-mapper.sh. --map-option=1 --map-option=2 --map-option=3 --common-option-one=one --common-option-two=two
```
Will be mapped into threee invocations of the target program as following:
```bash
target.sh --map-option=1 --common-option-one=one --common-option-two=two
target.sh --map-option=2 --common-option-one=one --common-option-two=two
target.sh --map-option=3 --common-option-one=one --common-option-two=two
```
Mapper supports dependent options to prevent collisions between multiple invocations.
## Example:
```
option-mapper.sh. --map-option=1 --map-option=2 --map-option=3 --common-option-two=one --dependent-option-one=two
```
Will be mapped as following:
```bash
target.sh --map-option=1 --common-option-one=one --dependent-option-one=invocation_1_two
target.sh --map-option=2 --common-option-one=one --dependent-option-one=invocation_2_two
target.sh --map-option=3 --common-option-one=one --dependent-option-one=invocation_3_two
```
## Synopsys Detect Example
detect-example.sh will utilize option mapper to allow specifying multiple --detect.source.path options at once.
This will place scans generated by each invocation of synopsys detect under the same project and version.
## PowerShell Detect example
detect-option-mapper.ps1 will implement similar functionality with windows PowerShell
E.g.
```
& .\detect-option-mapper.ps1 `
--detect.source.path=part1 `
--detect.source.path=part2 `
--detect.source.path='part 3' `
--blackduck.trust.cert=true `
--blackduck.url='https://ec2-3-236-71-181.compute-1.amazonaws.com' `
--blackduck.api.token='MTNlMDZhMjItNmU3ZC00OThhLWJkMGItOGNjZjE5YTg5N2UzOmM3ZmJjZDZmLWVkODUtNDZiYS1hZjE2LWQ4NGNjMGQ2NGI0NA==' `
--detect.project.name=FOO `
--detect.project.version.name=BAR
```
Will be translated into the following invocation sequence:
```
powershell "[Net.ServicePointManager]::SecurityProtocol = 'tls12'; Invoke-RestMethod https://detect.synopsys.com/detect.ps1?$(Get-Random) | Invoke-Expression ; detect " `
--detect.source.path=part1 `
--blackduck.trust.cert=true `
--blackduck.url=https://ec2-3-236-71-181.compute-1.amazonaws.com `
--blackduck.api.token=MTNlMDZhMjItNmU3ZC00OThhLWJkMGItOGNjZjE5YTg5N2UzOmM3ZmJjZDZmLWVkODUtNDZiYS1hZjE2LWQ4NGNjMGQ2NGI0NA== `
--detect.project.name=FOO `
--detect.project.version.name=BAR
. . .
powershell "[Net.ServicePointManager]::SecurityProtocol = 'tls12'; Invoke-RestMethod https://detect.synopsys.com/detect.ps1?$(Get-Random) | Invoke-Expression ; detect " `
--detect.source.path=part2 `
--blackduck.trust.cert=true `
--blackduck.url=https://ec2-3-236-71-181.compute-1.amazonaws.com `
--blackduck.api.token=MTNlMDZhMjItNmU3ZC00OThhLWJkMGItOGNjZjE5YTg5N2UzOmM3ZmJjZDZmLWVkODUtNDZiYS1hZjE2LWQ4NGNjMGQ2NGI0NA== `
--detect.project.name=FOO `
--detect.project.version.name=BAR
. . .
powershell "[Net.ServicePointManager]::SecurityProtocol = 'tls12'; Invoke-RestMethod https://detect.synopsys.com/detect.ps1?$(Get-Random) | Invoke-Expression ; detect " `
--detect.source.path=part` 3 `
--blackduck.trust.cert=true `
--blackduck.url=https://ec2-3-236-71-181.compute-1.amazonaws.com `
--blackduck.api.token=MTNlMDZhMjItNmU3ZC00OThhLWJkMGItOGNjZjE5YTg5N2UzOmM3ZmJjZDZmLWVkODUtNDZiYS1hZjE2LWQ4NGNjMGQ2NGI0NA== `
--detect.project.name=FOO `
--detect.project.version.name=BAR
. . .
```