Skip to content

Commit

Permalink
SCP-65 SBOM Ingestion
Browse files Browse the repository at this point in the history
  • Loading branch information
isasmendiagus committed Jan 24, 2024
1 parent e8b3826 commit b9081a4
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
- name: Test Local Action
id: test-action
uses: ./
# with:
# sbom-ignore: './scanoss-ignore.json'

- name: Print output command
run: echo "${{ steps.test-action.outputs.output-command }}"
Expand Down
13 changes: 11 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@ branding:

# Define your inputs here.
inputs:
scanner-parameters:
description: 'Parameters to run a scan'
sbom-identify:
description: 'Scan and identify components in SBOM file'
required: false
sbom-ignore:
description: 'Ignore components specified in the SBOM file'
required: false
api-key:
description: 'SCANOSS API Key token (optional - not required for default OSSKB URL)'
required: false
api-url:
description: 'SCANOSS API URL (optional - default: https://osskb.org/api/scan/direct)'
required: false

# Define your outputs here.
Expand Down
90 changes: 81 additions & 9 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions scanoss-ignore.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"components": [
{
"purl": "pkg:github/zhang14725804/notebook"
}
]
}
29 changes: 29 additions & 0 deletions src/input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as core from '@actions/core'

export interface ActionParameters {
sbomIdentify: string
sbomIgnore: string
apiKey: string
apiUrl: string
}

export function getInputs(): ActionParameters {
return {
sbomIdentify: core.getInput('sbom-identify'),
sbomIgnore: core.getInput('sbom-ignore'),
apiKey: core.getInput('api-key'),
apiUrl: core.getInput('api-url')
}
}

export function commandParametersBuilder(ap: ActionParameters): string {
return ap.sbomIdentify
? `--identify ${ap.sbomIdentify}`
: '' + ap.sbomIgnore
? `--ignore ${ap.sbomIgnore}`
: '' + ap.apiUrl
? `--apiurl ${ap.apiUrl}`
: '' + ap.apiKey
? `--key ${ap.apiKey}`
: ''
}
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import { getLicenses, readResult } from './services/result.service'
import { commandParametersBuilder } from './input'
import { getInputs } from './input'

/**
* The main function for the action.
Expand All @@ -25,7 +27,7 @@ export async function run(): Promise<void> {

// run scan
await exec.exec(
`docker run -v "${repoDir}":"/scanoss" ghcr.io/scanoss/scanoss-py:v1.9.0 scan . --output ${outputPath}`,
`docker run -v "${repoDir}":"/scanoss" ghcr.io/scanoss/scanoss-py:v1.9.0 scan . --output ${outputPath} ${commandParametersBuilder(getInputs())}`,
[],
options
)
Expand Down
56 changes: 56 additions & 0 deletions vue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<template>
<div>
<div :class="class1"></div>
<div :class="class2"></div>
<div class="box" :class="class3"></div>
<div class="box" :class="class4"></div>
<div class="box" :class="{ box5: class5 }"></div>
</div>
</template>

<style scoped>
.box {
width: 100px;
height: 100px;
}

.box1 {
background-color: #DDD;
}

.box2 {
background-color: #CCC;
}

.box3 {
background-color: #BBB;
}

.box4 {
background-color: #AAA;
}

.box5 {
background-color: #999;
}
</style>

<script>
module.exports = {
data () {
return {
class1: ['box', 'box1'],
class2: {
'box': true,
'box1': false,
'box2': true
},
class3: ['box3'],
class4: {
'box4': true
},
class5: true
}
}
}
</script>

0 comments on commit b9081a4

Please sign in to comment.