Skip to content

Commit a2bdb89

Browse files
feat(DATAGO-123600): Introduce fossa container scan and guard shareable workflow/actions (#65)
* feat: make SCA scan workflow flexible for Vault and GitHub Secrets Add support for both Vault (private repos) and GitHub Secrets (public repos) through conditional secret retrieval: Key Changes: - Add use_vault input flag (default: false) for secret source selection - Add vault_url, vault_role, vault_secret_path inputs for Vault config - Add FOSSA_API_KEY as workflow secret input for GitHub Secrets mode - Remove hard-coded VAULT_ADDR environment variable - Make Vault retrieval step conditional based on use_vault flag - Add validation step to ensure API key from either source - Update all FOSSA API key references to use unified output - Update documentation with examples for both public and private repos Benefits: - Single workflow works for both public and private repos - No hard-coded Vault URLs in public workflow - Clear validation and error messages - Backward compatible with migration path Usage: - Public repos: Pass FOSSA_API_KEY via secrets (default) - Private repos: Set use_vault=true and provide vault_url 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: add container scan and guard workflow with config support - Added reusable container-scan-and-guard.yaml workflow - Created workflow-config-loader action for centralized configuration - Added container scanning actions (container-scan, fossa-scan, prisma-scan) - Supports both Vault and GitHub Secrets for credential management - Includes AWS ECR authentication for private registries - Config-based approach reduces workflow inputs from 15+ to 6 - Added comprehensive documentation and architecture guides * chore: ignore pilot-repos directory * feat: use container image tag as FOSSA revision - Extract image tag from container_image input - Use tag as FOSSA revision instead of git ref - For container scans, the image tag is more meaningful than git SHA - Added image tag to workflow summary output * refactor: remove git_ref input and second checkout - Removed git_ref input parameter (no longer needed) - Removed second checkout step that used git_ref - Simplified context detection to PR vs Non-PR (instead of PR/Release/Manual) - Container image tag is the FOSSA revision (from container_image input) - Config file is loaded in first checkout, no second checkout needed - Updated documentation and usage examples to remove git_ref references 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: add FOSSA team and labels support for container scans - Added team and labels fields to workflow-config.json schema - Updated workflow-config-loader to parse and output fossa_team and fossa_labels - Modified container-scan-and-guard to build scan params with team and labels - Team and labels are now passed to FOSSA container analyze command - Conditionally added only when configured in workflow-config.json 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * chore: remove unused load-workflow-config workflow and simplify prisma-scan - Remove .github/workflows/load-workflow-config.yaml (unused, replaced by workflow-config-loader action) - Simplify container/prisma-scan/action.yaml to testing placeholder - Action approach provides better integration than separate workflow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: simplify prisma-scan README as placeholder - Update README to clearly indicate placeholder status - Remove detailed documentation for unimplemented features - Add brief description of current behavior (dummy outputs) - Reference related documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: move container scan architecture to cicd-processes-docs - Remove container-scan-config-architecture.md from this repo - Document now maintained in SolaceDev/cicd-processes-docs - Centralize design docs in dedicated documentation repository Reference: https://github.com/SolaceDev/cicd-processes-docs/blob/main/processes/security-scanning/design/container-scan-config-architecture.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: add comprehensive README for workflow-config-loader - Add detailed documentation for workflow-config-loader action - Include quick start examples for Vault and GitHub Secrets - Document all inputs, outputs, and configuration schema - Provide migration guide from workflow inputs to config file - Add usage examples and error handling documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: refine workflow-config-schema for end-users - Move schema to workflow-config-loader directory - Remove efficiency/implementation details - Focus only on configuration fields users need - Add team and labels configuration documentation - Simplify examples to common use cases - Remove Prisma references (not yet implemented) - Update related documentation links 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor: use environment variables in shell steps for security Following GitHub Actions security best practices, refactored all inline shell steps to use environment variables instead of direct GitHub expression interpolation. This prevents script injection attacks by storing expression values in memory as variables rather than allowing them to interact with the script generation process. Changes: - Added env blocks to all shell steps with GitHub expressions - Replaced inline ${{ ... }} with environment variable references - Applied double-quoting to all variable references for word splitting safety Steps updated: - Validate Container Image Input - Merge Configuration and Inputs - Determine scan context - Determine Vault AWS Role - Validate FOSSA API Key - Determine FOSSA Project ID - Build FOSSA Scan Parameters - Report Container Scan Results - Block on FOSSA Vulnerability Failures - Log Emergency Bypass References: https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * clean up * change references to main branch after testing --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1a75706 commit a2bdb89

File tree

13 files changed

+2611
-0
lines changed

13 files changed

+2611
-0
lines changed

.github/workflows/container-scan-and-guard.yaml

Lines changed: 624 additions & 0 deletions
Large diffs are not rendered by default.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,4 @@ cython_debug/
161161
# and can be added to the global gitignore or merged into this file. For a more nuclear
162162
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
163163
#.idea/
164+
pilot-repos/

container/container-scan/README.md

Lines changed: 347 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,347 @@
1+
# Container Scan Action
2+
3+
Unified orchestrator for container image security and compliance scanning. Supports multiple scanning tools including FOSSA and Prisma Cloud.
4+
5+
## Overview
6+
7+
This action provides a single interface to run container image scans using various security tools. It:
8+
- Orchestrates multiple container scanners
9+
- Provides a consistent parameter interface
10+
- Allows flexible scanner selection
11+
- Supports scanner-specific configuration
12+
13+
## Supported Scanners
14+
15+
| Scanner | Purpose | Documentation |
16+
|---------|---------|---------------|
17+
| `fossa` | License compliance and vulnerability detection | [fossa-scan README](../fossa-scan/README.md) |
18+
| `prisma` | Container security scanning with Prisma Cloud | [prisma-scan README](../prisma-scan/README.md) |
19+
20+
## Usage
21+
22+
### Basic Scan with FOSSA
23+
24+
```yaml
25+
- name: Scan Container Image
26+
uses: SolaceDev/solace-public-workflows/container/container-scan@main
27+
with:
28+
scanners: "fossa"
29+
additional_scan_params: |
30+
fossa.image=ghcr.io/solacedev/my-app:v1.0.0
31+
fossa_api_key: ${{ secrets.FOSSA_API_KEY }}
32+
```
33+
34+
### Scan with Multiple Scanners
35+
36+
```yaml
37+
- name: Scan Container Image
38+
uses: SolaceDev/solace-public-workflows/container/container-scan@main
39+
with:
40+
scanners: "fossa,prisma"
41+
additional_scan_params: |
42+
fossa.image=ghcr.io/solacedev/my-app:v1.0.0
43+
fossa.project=MyOrg_my-app
44+
prisma.image_registry=ghcr.io
45+
prisma.image_repo=solacedev/my-app
46+
prisma.image_tag=v1.0.0
47+
fossa_api_key: ${{ secrets.FOSSA_API_KEY }}
48+
prisma_console_url: ${{ secrets.PRISMA_CONSOLE_URL }}
49+
prisma_user: ${{ secrets.PRISMA_USER }}
50+
prisma_pass: ${{ secrets.PRISMA_PASS }}
51+
```
52+
53+
### Complete Workflow Example
54+
55+
```yaml
56+
name: Container Scan
57+
58+
on:
59+
push:
60+
branches: [main]
61+
pull_request:
62+
63+
jobs:
64+
scan:
65+
runs-on: ubuntu-latest
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v4
69+
70+
- name: Login to GHCR
71+
uses: docker/login-action@v3
72+
with:
73+
registry: ghcr.io
74+
username: ${{ github.actor }}
75+
password: ${{ secrets.GITHUB_TOKEN }}
76+
77+
- name: Build Container Image
78+
run: |
79+
docker build -t ghcr.io/solacedev/my-app:${{ github.sha }} .
80+
docker push ghcr.io/solacedev/my-app:${{ github.sha }}
81+
82+
- name: Scan Container
83+
uses: SolaceDev/solace-public-workflows/container/container-scan@main
84+
with:
85+
scanners: "fossa"
86+
additional_scan_params: |
87+
fossa.image=ghcr.io/solacedev/my-app:${{ github.sha }}
88+
fossa.project=MyOrg_my-app
89+
fossa.branch=${{ github.ref_name }}
90+
fossa.revision=${{ github.sha }}
91+
fossa_api_key: ${{ secrets.FOSSA_API_KEY }}
92+
```
93+
94+
## Inputs
95+
96+
### Required Inputs (Scanner-Dependent)
97+
98+
The required inputs depend on which scanners you're using. See individual scanner documentation for details.
99+
100+
### Common Inputs
101+
102+
| Input | Description | Default | Required |
103+
|-------|-------------|---------|----------|
104+
| `scanners` | Comma-separated list of scanners | `"fossa"` | No |
105+
| `additional_scan_params` | Scanner-specific parameters (see below) | `""` | No |
106+
107+
### FOSSA Inputs
108+
109+
| Input | Description | Required |
110+
|-------|-------------|----------|
111+
| `fossa_api_key` | FOSSA API key | Yes (if using fossa) |
112+
113+
### Prisma Cloud Inputs
114+
115+
| Input | Description | Required |
116+
|-------|-------------|----------|
117+
| `prisma_console_url` | Prisma Cloud Console URL | Yes (if using prisma) |
118+
| `prisma_user` | Prisma Cloud Access Key | Yes (if using prisma) |
119+
| `prisma_pass` | Prisma Cloud Secret Key | Yes (if using prisma) |
120+
121+
## Parameter System
122+
123+
The `additional_scan_params` input uses a flexible key-value format:
124+
125+
```yaml
126+
additional_scan_params: |
127+
scanner.parameter=value
128+
scanner.another_param=value
129+
```
130+
131+
Parameters are automatically converted to environment variables:
132+
- `fossa.image=ghcr.io/repo:tag` → `CONTAINER_FOSSA_IMAGE=ghcr.io/repo:tag`
133+
- `prisma.image_registry=ghcr.io` → `CONTAINER_PRISMA_IMAGE_REGISTRY=ghcr.io`
134+
135+
### FOSSA Parameters
136+
137+
| Parameter | Description | Example |
138+
|-----------|-------------|---------|
139+
| `fossa.image` | Container image to scan (REQUIRED) | `ghcr.io/solacedev/my-app:v1.0.0` |
140+
| `fossa.project` | Project name override | `MyOrg_my-app` |
141+
| `fossa.branch` | Branch name | `main` |
142+
| `fossa.revision` | Git commit SHA | `abc123` |
143+
| `fossa.skip_test` | Skip policy test | `true` |
144+
| `fossa.debug` | Enable debug logging | `true` |
145+
146+
See [fossa-scan README](../fossa-scan/README.md) for complete parameter list.
147+
148+
### Prisma Cloud Parameters
149+
150+
| Parameter | Description | Example |
151+
|-----------|-------------|---------|
152+
| `prisma.image_registry` | Container registry | `ghcr.io` |
153+
| `prisma.image_repo` | Repository name | `solacedev/my-app` |
154+
| `prisma.image_tag` | Image tag | `v1.0.0` |
155+
156+
See [prisma-scan README](../prisma-scan/README.md) for complete parameter list.
157+
158+
## Examples
159+
160+
### Scan Docker Hub Image
161+
162+
```yaml
163+
- uses: SolaceDev/solace-public-workflows/container/container-scan@main
164+
with:
165+
scanners: "fossa"
166+
additional_scan_params: |
167+
fossa.image=solace/pubsubplus:latest
168+
fossa_api_key: ${{ secrets.FOSSA_API_KEY }}
169+
```
170+
171+
### Scan GHCR Image with Custom Project Name
172+
173+
```yaml
174+
- uses: SolaceDev/solace-public-workflows/container/container-scan@main
175+
with:
176+
scanners: "fossa"
177+
additional_scan_params: |
178+
fossa.image=ghcr.io/solacedev/my-app:v1.0.0
179+
fossa.project=MyOrg_my-app-container
180+
fossa.team=Platform Team
181+
fossa_api_key: ${{ secrets.FOSSA_API_KEY }}
182+
```
183+
184+
### Scan AWS ECR Image
185+
186+
```yaml
187+
- name: Login to ECR
188+
uses: aws-actions/amazon-ecr-login@v2
189+
190+
- uses: SolaceDev/solace-public-workflows/container/container-scan@main
191+
with:
192+
scanners: "fossa"
193+
additional_scan_params: |
194+
fossa.image=123456789012.dkr.ecr.us-east-1.amazonaws.com/my-app:v1.0.0
195+
fossa_api_key: ${{ secrets.FOSSA_API_KEY }}
196+
```
197+
198+
### Debug Mode
199+
200+
```yaml
201+
- uses: SolaceDev/solace-public-workflows/container/container-scan@main
202+
with:
203+
scanners: "fossa"
204+
additional_scan_params: |
205+
fossa.image=ghcr.io/solacedev/my-app:v1.0.0
206+
fossa.debug=true
207+
fossa_api_key: ${{ secrets.FOSSA_API_KEY }}
208+
```
209+
210+
### Skip Policy Test
211+
212+
```yaml
213+
- uses: SolaceDev/solace-public-workflows/container/container-scan@main
214+
with:
215+
scanners: "fossa"
216+
additional_scan_params: |
217+
fossa.image=ghcr.io/solacedev/my-app:v1.0.0
218+
fossa.skip_test=true
219+
fossa_api_key: ${{ secrets.FOSSA_API_KEY }}
220+
```
221+
222+
## Registry Authentication
223+
224+
Most container registries require authentication. Ensure you authenticate before scanning:
225+
226+
### GitHub Container Registry (GHCR)
227+
228+
```yaml
229+
- uses: docker/login-action@v3
230+
with:
231+
registry: ghcr.io
232+
username: ${{ github.actor }}
233+
password: ${{ secrets.GITHUB_TOKEN }}
234+
```
235+
236+
### AWS ECR
237+
238+
```yaml
239+
- uses: aws-actions/amazon-ecr-login@v2
240+
```
241+
242+
### Docker Hub
243+
244+
```yaml
245+
- uses: docker/login-action@v3
246+
with:
247+
username: ${{ secrets.DOCKERHUB_USERNAME }}
248+
password: ${{ secrets.DOCKERHUB_TOKEN }}
249+
```
250+
251+
## How It Works
252+
253+
1. **Parameter Parsing**: Converts `additional_scan_params` into environment variables with `CONTAINER_*` prefix
254+
2. **Scanner Execution**: Runs requested scanners conditionally based on `scanners` input
255+
3. **Results**: Each scanner reports results independently
256+
257+
### Parameter Conversion Flow
258+
259+
```
260+
Input:
261+
additional_scan_params: |
262+
fossa.image=ghcr.io/solacedev/my-app:v1.0.0
263+
fossa.project=MyOrg_my-app
264+
265+
Conversion:
266+
CONTAINER_FOSSA_IMAGE=ghcr.io/solacedev/my-app:v1.0.0
267+
CONTAINER_FOSSA_PROJECT=MyOrg_my-app
268+
269+
Usage by Scanner:
270+
fossa-scan action reads CONTAINER_FOSSA_* variables
271+
Builds CLI: fossa container analyze ghcr.io/solacedev/my-app:v1.0.0 --project MyOrg_my-app
272+
```
273+
274+
## Architecture
275+
276+
```
277+
container-scan (orchestrator)
278+
├── Parses additional_scan_params
279+
├── Converts to CONTAINER_* env vars
280+
├── Conditionally calls:
281+
│ ├── fossa-scan (if 'fossa' in scanners)
282+
│ └── prisma-scan (if 'prisma' in scanners)
283+
```
284+
285+
Each scanner action:
286+
1. Reads `CONTAINER_SCANNER_*` environment variables
287+
2. Converts them to scanner-specific CLI arguments
288+
3. Executes the scanner
289+
4. Reports results
290+
291+
## Relationship to Other Actions
292+
293+
| Action | Purpose |
294+
|--------|---------|
295+
| [container/fossa-scan](../fossa-scan/README.md) | FOSSA container scanning (called by this action) |
296+
| [container/prisma-scan](../prisma-scan/README.md) | Prisma Cloud scanning (called by this action) |
297+
| [.github/actions/sca/sca-scan](../../.github/actions/sca/sca-scan/README.md) | Source code dependency scanning |
298+
299+
## Troubleshooting
300+
301+
### "Invalid additional_scan_params line"
302+
Ensure each line follows `key=value` format with no spaces around the `=`:
303+
```yaml
304+
# Good
305+
fossa.image=ghcr.io/repo:tag
306+
307+
# Bad
308+
fossa.image = ghcr.io/repo:tag
309+
```
310+
311+
### "Permission denied" accessing image
312+
Authenticate to the registry before scanning (see [Registry Authentication](#registry-authentication))
313+
314+
### Scanner not running
315+
Check that the scanner name is spelled correctly in the `scanners` input:
316+
```yaml
317+
scanners: "fossa" # Correct
318+
scanners: "FOSSA" # Wrong - case sensitive
319+
```
320+
321+
### Missing required parameters
322+
Each scanner has required parameters. For FOSSA:
323+
```yaml
324+
additional_scan_params: |
325+
fossa.image=ghcr.io/repo:tag # REQUIRED
326+
```
327+
328+
## Best Practices
329+
330+
1. **Always specify the full image path** including registry, repository, and tag
331+
2. **Use dynamic tags** in CI/CD (commit SHA, PR number) for traceability
332+
3. **Authenticate to registries** before scanning private images
333+
4. **Use secrets** for API keys and credentials
334+
5. **Set project metadata** (project, branch, revision) for better tracking in scanner dashboards
335+
336+
## Related Documentation
337+
338+
- [FOSSA Container Scan](../fossa-scan/README.md)
339+
- [Prisma Cloud Scan](../prisma-scan/README.md)
340+
- [SCA Scan](../../.github/actions/sca/sca-scan/README.md)
341+
342+
## Support
343+
344+
For issues or questions:
345+
- FOSSA scanning: See [FOSSA CLI documentation](https://github.com/fossas/fossa-cli)
346+
- Prisma scanning: See [Prisma Cloud documentation](https://docs.paloaltonetworks.com/prisma/prisma-cloud)
347+
- Action issues: Open an issue in the repository

0 commit comments

Comments
 (0)