Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
59e3d9f
Basesine for the action
tdruez Mar 28, 2023
4eb8052
Test workflow for the scan action
tdruez Mar 28, 2023
f9928da
Add missing shell: bash
tdruez Mar 28, 2023
c23cb09
Add missing shell: bash
tdruez Mar 28, 2023
5946fd5
Attempt to set env
tdruez Mar 28, 2023
6cbb1f1
Attempt to set env
tdruez Mar 28, 2023
4e59ed2
Attempt to set env
tdruez Mar 28, 2023
8671669
Attempt to set env
tdruez Mar 28, 2023
54e9ea2
Attempt to set env
tdruez Mar 28, 2023
037ab7f
Attempt to set env
tdruez Mar 28, 2023
2c94c41
Attempt to set env
tdruez Mar 28, 2023
6d3ebca
Single format
tdruez Mar 28, 2023
045c360
Debug upload
tdruez Mar 28, 2023
cde5cad
Debug upload
tdruez Mar 28, 2023
1ec7c0c
Re-enable all the steps
tdruez Jan 29, 2024
83df807
Set the env var in an .env file
tdruez Jan 29, 2024
e7d25c8
Use proper .env location
tdruez Jan 29, 2024
c4acc32
debug
tdruez Jan 29, 2024
1b44d91
debug
tdruez Jan 29, 2024
bb349ae
debug
tdruez Jan 29, 2024
f4aba86
debug
tdruez Jan 29, 2024
25ab555
debug
tdruez Jan 29, 2024
c331b11
debug
tdruez Jan 29, 2024
77b3010
debug
tdruez Jan 29, 2024
78a32c5
debug
tdruez Jan 29, 2024
44c66e7
debug
tdruez Jan 29, 2024
5a8c036
debug
tdruez Jan 29, 2024
07661a1
debug
tdruez Jan 29, 2024
ea87d6d
debug
tdruez Jan 29, 2024
32876e1
debug
tdruez Jan 29, 2024
1baf309
debug
tdruez Jan 29, 2024
844ba51
debug
tdruez Jan 29, 2024
896e043
debug
tdruez Jan 29, 2024
9c06262
debug
tdruez Jan 29, 2024
eadf78f
debug
tdruez Jan 29, 2024
137846d
debug
tdruez Jan 29, 2024
d0c686d
debug
tdruez Jan 29, 2024
f7db597
debug
tdruez Jan 29, 2024
d8b1423
debug
tdruez Jan 29, 2024
e088d31
debug
tdruez Jan 29, 2024
111daff
debug
tdruez Jan 29, 2024
334f1c8
debug
tdruez Jan 29, 2024
29e4d82
debug
tdruez Jan 29, 2024
d76407b
debug
tdruez Jan 29, 2024
e8f6cd1
debug
tdruez Jan 29, 2024
eb01d32
cleanup
tdruez Jan 29, 2024
4639512
cleanup
tdruez Jan 29, 2024
20d08af
Add README
tdruez Jan 29, 2024
2f2097d
Improve README
tdruez Jan 29, 2024
d9695ec
Use ${GITHUB_REPOSITORY} as default project name
tdruez Jan 30, 2024
f4df894
Set default project name
tdruez Jan 30, 2024
d23a862
Set default project name
tdruez Jan 30, 2024
db3de66
Set default project name
tdruez Jan 30, 2024
6c490c2
Set default project name
tdruez Jan 30, 2024
0b5d2fc
Revert changes
tdruez Jan 30, 2024
40d4240
Support for multiple pipelines
tdruez Jan 30, 2024
e16ce93
Support for multiple pipelines
tdruez Jan 30, 2024
43773d6
Support for multiple pipelines
tdruez Jan 30, 2024
5ad2862
Support for multiple pipelines
tdruez Jan 30, 2024
d763662
Improve docs
tdruez Jan 30, 2024
e4a81e9
Replace download by checkout action
tdruez Jan 30, 2024
fdd2826
Replace download by checkout action
tdruez Jan 30, 2024
22e6811
env
tdruez Jan 30, 2024
c6f27b7
env
tdruez Jan 30, 2024
934afbd
env
tdruez Jan 30, 2024
0fa9211
env
tdruez Jan 30, 2024
7145b19
docs
tdruez Jan 30, 2024
cf84010
postgres
tdruez Jan 30, 2024
6deb8b2
debug
tdruez Jan 30, 2024
83dbf9b
debug
tdruez Jan 30, 2024
12d7e26
debug
tdruez Jan 30, 2024
f8a4242
debug
tdruez Jan 30, 2024
8876e4f
debug
tdruez Jan 30, 2024
b420384
debug
tdruez Jan 30, 2024
44be1eb
debug
tdruez Jan 30, 2024
223d55e
debug
tdruez Jan 30, 2024
d45a4ea
debug
tdruez Jan 30, 2024
e9e161b
debug
tdruez Jan 30, 2024
3ddab4e
debug
tdruez Jan 30, 2024
b910a41
debug
tdruez Jan 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/scan-codebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on: [push]

jobs:
scan-codebase:
runs-on: ubuntu-latest
name: Scan codebase with ScanCode.io
steps:
- uses: actions/checkout@v4
with:
path: scancode-inputs
- uses: nexB/scancode-action@alpha
with:
pipelines: "scan_codebase,find_vulnerabilities"
env:
VULNERABLECODE_URL: https://public.vulnerablecode.io/
13 changes: 13 additions & 0 deletions .github/workflows/scan-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
on: [push]

jobs:
scan-codebase:
runs-on: ubuntu-latest
name: Scan package with ScanCode.io
steps:
- name: Download repository archive to scancode-inputs/ directory
run: |
wget --directory-prefix=scancode-inputs https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_REF}.zip
- uses: nexB/scancode-action@alpha
with:
pipelines: "scan_package"
98 changes: 98 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Ignore node_modules, ncc is used to compile nodejs modules into a single file in the releases branch
node_modules/
__tests__/runner/*

# Ignore js files that are transpiled from ts files in src/
lib/

# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Editor
.idea
142 changes: 140 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,140 @@
# scancode-action
Run ScanCode scan in your workflow
# `@nexB/scancode-action`

Run [ScanCode.io](https://github.com/nexB/scancode.io) pipelines from your Workflows.

> [!IMPORTANT]
> The scancode-action is currently in the **alpha stage**, and we invite you to
> contribute to its improvement. Please feel free to submit bug reports or share
> your ideas by creating new entries in the "Issues" section.
> Your collaboration helps us enhance the action and ensures a more stable and
> effective tool for the community.
> Thank you for your support!

- [Usage](#usage)
- [Basic](#basic)
- [Inputs](#inputs)
- [Examples](#examples)
- [Scan repo codebase](#scan-repo-codebase)
- [Run a specific pipeline](#run-a-specific-pipeline)
- [Run multiple pipelines](#run-multiple-pipelines)
- [Choose the output formats](#choose-the-output-formats)
- [Fetch pipelines inputs](#fetch-pipelines-inputs)
- [Define a custom project name](#define-a-custom-project-name)
- [Where does the scan results go?](#where-does-the-scan-results-go)

## Usage

### Basic

```yaml
steps:
- uses: actions/checkout@v4
with:
path: scancode-inputs
- uses: nexB/scancode-action@alpha
with:
pipelines: "scan_codebase"
output-formats: "json xlsx spdx cyclonedx"
```

### Inputs

```yaml
- uses: nexB/scancode-action@alpha
with:
# Names of the pipelines (comma-separated) and in order.
# Default is 'scan_codebase'
pipelines:

# The list of output formats to generate.
# Default is 'json xlsx spdx cyclonedx'
output-formats:

# Relative path within the $GITHUB_WORKSPACE for pipeline inputs.
# Default is 'scancode-inputs'
inputs-path:

# Name of the project.
# Default is 'scancode-action'
project-name:

# Python version that will be installed to run ScanCode.io
# Default is '3.11'
python-version:
```

## Examples

### Scan repo codebase

```yaml
steps:
- uses: actions/checkout@v4
with:
path: scancode-inputs
- uses: nexB/scancode-action@alpha
```

### Run a specific pipeline

[Built-in pipelines list](https://scancodeio.readthedocs.io/en/latest/built-in-pipelines.html)

```yaml
- uses: nexB/scancode-action@alpha
with:
pipelines: "scan_codebase"
```

### Run multiple pipelines

```yaml
- uses: nexB/scancode-action@alpha
with:
pipelines: "scan_codebase,find_vulnerabilities"
env:
VULNERABLECODE_URL: https://public.vulnerablecode.io/
```

#### Configuring `find_vulnerabilities` Pipeline

The `find_vulnerabilities` pipeline requires access to a VulnerableCode instance,
which can be defined using the `VULNERABLECODE_URL` environment variable.

In the example provided, a public instance is referenced.
However, you also have the option to run your own VulnerableCode instance.
For details on setting up and configuring your own instance, please refer to the
[VulnerableCode documentation](https://vulnerablecode.readthedocs.io/en/latest/index.html).

### Choose the output formats

```yaml
- uses: nexB/scancode-action@alpha
with:
output-formats: "json xlsx spdx cyclonedx"
```

### Fetch pipelines inputs

```yaml
- name: Download repository archive to scancode-inputs/ directory
run: |
wget --directory-prefix=scancode-inputs https://github.com/${GITHUB_REPOSITORY}/archive/${GITHUB_REF}.zip
- uses: nexB/scancode-action@alpha
with:
pipelines: "scan_single_package"
```

### Define a custom project name

```yaml
- uses: nexB/scancode-action@alpha
with:
project-name: "my-project-name"
```

## Where are the Scan Results?

Upon completion of the workflow, you can **find the scan results** in the dedicated
**artifacts section** at the bottom of the workflow summary page.
Look for a file named `scanpipe-outputs` in that section.
This file contains the outputs generated by the `scancode-action`.
83 changes: 83 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: "ScanCode action"
description: "Run ScanCode.io pipelines in your workflows"
inputs:
pipelines:
description: "Names of the pipelines (comma-separated) and in order."
default: "scan_codebase"
output-formats:
description: "Output formats"
default: "json xlsx spdx cyclonedx"
inputs-path:
description: "Relative path within the $GITHUB_WORKSPACE for pipeline inputs"
default: "${{ github.workspace }}/scancode-inputs"
project-name:
description: "Name of the project"
default: "scancode-action"
python-version:
description: "Python version"
default: "3.11"

runs:
using: "composite"
steps:
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Set up environment
shell: bash
run: |
echo "SECRET_KEY=$(openssl rand -base64 32)" >> $GITHUB_ENV
echo "SCANCODEIO_DB_ENGINE=django.db.backends.sqlite3" >> $GITHUB_ENV
echo "SCANCODEIO_DB_NAME=sqlite3.db" >> $GITHUB_ENV

- name: Install ScanCode.io
shell: bash
run: |
pip install scancodeio
scanpipe migrate

- name: Generate pipelines CLI arguments
shell: bash
run: |
IFS=',' read -ra PIPELINES <<< "${{ inputs.pipelines }}"
options=""
for pipeline in "${PIPELINES[@]}"; do
options+="--pipeline $pipeline "
done
echo "PIPELINE_CLI_ARGS=${options}" >> $GITHUB_ENV

- name: Create project with ${{ inputs.pipelines }} pipelines
shell: bash
run: |
scanpipe create-project ${{ inputs.project-name }} ${{ env.PIPELINE_CLI_ARGS }}

- name: Set project work directory in the environment
shell: bash
run: |
project_status=$(scanpipe status --project ${{ inputs.project-name }})
work_directory=$(echo "$project_status" | grep -oP 'Work directory:\s*\K[^\n]+')
echo "PROJECT_WORK_DIRECTORY=$work_directory" >> $GITHUB_ENV

- name: Copy input files to project work directory
shell: bash
run: cp -r ${{ inputs.inputs-path }}/* ${{ env.PROJECT_WORK_DIRECTORY }}/input/

- name: Run the pipelines
shell: bash
run: scanpipe execute --project ${{ inputs.project-name }} --no-color

- name: Generate outputs
id: scanpipe
shell: bash
run: scanpipe output
--project ${{ inputs.project-name }}
--format ${{ inputs.output-formats }}
--no-color

- name: Upload outputs
uses: actions/upload-artifact@v4
id: artifact-upload-step
with:
name: scanpipe-outputs
path: ${{ env.PROJECT_WORK_DIRECTORY }}/output/*