From fd6fbc7ba3b6d7d8ab53abfcd06632678f2ff491 Mon Sep 17 00:00:00 2001 From: John Corpuz Date: Mon, 22 Dec 2025 11:19:49 -0500 Subject: [PATCH 01/13] feat: Add support for custom FOSSA config and path parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds support for `fossa.config` and `fossa.path` via the existing `additional_scan_params` mechanism to enable monorepo per-project scanning. Changes: - Add `--path` flag support via `fossa.path` parameter - Add `--config` flag support via `fossa.config` parameter - Both parameters are optional and backward compatible Usage example: ```yaml additional_scan_params: | fossa.path=sam-mongodb fossa.config=sam-mongodb/.fossa.yml fossa.project=my-plugin ``` This allows scanning specific subdirectories with their own .fossa.yml configuration files, which is essential for monorepo workflows where each plugin needs independent FOSSA project tracking. ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/actions/sca/fossa-scan/action.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/actions/sca/fossa-scan/action.yaml b/.github/actions/sca/fossa-scan/action.yaml index a098892..bf909ef 100644 --- a/.github/actions/sca/fossa-scan/action.yaml +++ b/.github/actions/sca/fossa-scan/action.yaml @@ -44,6 +44,18 @@ runs: SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS --force-vendored-dependency-rescans" fi + # Add --path if SCA_FOSSA_PATH is provided + if [ -n "${{ env.SCA_FOSSA_PATH }}" ]; then + SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS --path ${{ env.SCA_FOSSA_PATH }}" + echo "Using FOSSA path: ${{ env.SCA_FOSSA_PATH }}" + fi + + # Add --config if SCA_FOSSA_CONFIG is provided + if [ -n "${{ env.SCA_FOSSA_CONFIG }}" ]; then + SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS --config ${{ env.SCA_FOSSA_CONFIG }}" + echo "Using FOSSA config: ${{ env.SCA_FOSSA_CONFIG }}" + fi + echo "SCA_FOSSA_ADDITIONAL_ARGS=${SCA_FOSSA_ADDITIONAL_ARGS}" >> "$GITHUB_ENV" # Set up test args with only revision parameter From e4cffa75b434765f3d42c9836c8025706a20cd24 Mon Sep 17 00:00:00 2001 From: John Corpuz Date: Mon, 22 Dec 2025 11:21:40 -0500 Subject: [PATCH 02/13] refactor: Simplify parameter handling with declarative mapping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace individual if-blocks with a loop-based parameter mapping system for easier maintenance and extensibility. Benefits: - Reduces code from ~50 lines to ~35 lines - Adding new parameters now requires only one line - Self-documenting parameter format: ENV_VAR:--flag:type - Maintains backward compatibility Example of adding a new parameter: ```bash "SCA_FOSSA_NEW_PARAM:--new-param:value" ``` ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/actions/sca/fossa-scan/action.yaml | 74 ++++++++++------------ 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/.github/actions/sca/fossa-scan/action.yaml b/.github/actions/sca/fossa-scan/action.yaml index bf909ef..3859d23 100644 --- a/.github/actions/sca/fossa-scan/action.yaml +++ b/.github/actions/sca/fossa-scan/action.yaml @@ -14,47 +14,39 @@ runs: SCA_FOSSA_ADDITIONAL_ARGS="" - #if SCA_FOSSA_ANALYZE_DEBUG is set to true, add --debug to analyze args - if [ "${{ env.SCA_FOSSA_ANALYZE_DEBUG }}" == "true" ]; then - SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS --debug" - fi - - # Set branch parameter if SCA_FOSSA_BRANCH environment variable is provided - if [ -n "${{ env.SCA_FOSSA_BRANCH }}" ]; then - SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS --branch ${{ env.SCA_FOSSA_BRANCH }}" - fi - - # Set revision parameter if SCA_FOSSA_REVISION environment variable is provided - if [ -n "${{ env.SCA_FOSSA_REVISION }}" ]; then - SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS --revision ${{ env.SCA_FOSSA_REVISION }}" - fi - - # Add --unpack-archives if SCA_FOSSA_UNPACK_ARCHIVES is set to true - if [ "${{ env.SCA_FOSSA_UNPACK_ARCHIVES }}" == "true" ]; then - SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS --unpack-archives" - fi - - # Add --without-default-filters if SCA_FOSSA_WITHOUT_DEFAULT_FILTERS is set to true - if [ "${{ env.SCA_FOSSA_WITHOUT_DEFAULT_FILTERS }}" == "true" ]; then - SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS --without-default-filters" - fi - - # Add --force-vendored-dependency-rescans if SCA_FOSSA_FORCE_VENDORED_DEPENDENCY_RESCANS is set to true - if [ "${{ env.SCA_FOSSA_FORCE_VENDORED_DEPENDENCY_RESCANS }}" == "true" ]; then - SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS --force-vendored-dependency-rescans" - fi - - # Add --path if SCA_FOSSA_PATH is provided - if [ -n "${{ env.SCA_FOSSA_PATH }}" ]; then - SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS --path ${{ env.SCA_FOSSA_PATH }}" - echo "Using FOSSA path: ${{ env.SCA_FOSSA_PATH }}" - fi - - # Add --config if SCA_FOSSA_CONFIG is provided - if [ -n "${{ env.SCA_FOSSA_CONFIG }}" ]; then - SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS --config ${{ env.SCA_FOSSA_CONFIG }}" - echo "Using FOSSA config: ${{ env.SCA_FOSSA_CONFIG }}" - fi + # Define parameter mappings: ENV_VAR_NAME:CLI_FLAG:VALUE_TYPE + # VALUE_TYPE can be: "flag" (boolean flag), "value" (flag with value) + FOSSA_PARAMS=( + "SCA_FOSSA_ANALYZE_DEBUG:--debug:flag" + "SCA_FOSSA_BRANCH:--branch:value" + "SCA_FOSSA_REVISION:--revision:value" + "SCA_FOSSA_PATH:--path:value" + "SCA_FOSSA_CONFIG:--config:value" + "SCA_FOSSA_UNPACK_ARCHIVES:--unpack-archives:flag" + "SCA_FOSSA_WITHOUT_DEFAULT_FILTERS:--without-default-filters:flag" + "SCA_FOSSA_FORCE_VENDORED_DEPENDENCY_RESCANS:--force-vendored-dependency-rescans:flag" + ) + + # Process each parameter + for param in "${FOSSA_PARAMS[@]}"; do + IFS=':' read -r env_var cli_flag value_type <<< "$param" + + # Get the environment variable value + env_value="${!env_var}" + + if [ "$value_type" == "flag" ]; then + # Boolean flag - only add if set to "true" + if [ "$env_value" == "true" ]; then + SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS $cli_flag" + fi + elif [ "$value_type" == "value" ]; then + # Flag with value - only add if value is non-empty + if [ -n "$env_value" ]; then + SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS $cli_flag $env_value" + echo "Using FOSSA $cli_flag: $env_value" + fi + fi + done echo "SCA_FOSSA_ADDITIONAL_ARGS=${SCA_FOSSA_ADDITIONAL_ARGS}" >> "$GITHUB_ENV" From fc4c770ed5e7e64bc414fda26c0132988b1481a6 Mon Sep 17 00:00:00 2001 From: John Corpuz Date: Mon, 22 Dec 2025 12:58:17 -0500 Subject: [PATCH 03/13] refactor: Implement JSON-based parameter configuration system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Complete refactor to use declarative JSON configuration for FOSSA CLI parameters, making the action more maintainable and easier to extend. **New Files:** - `fossa-params.json` - Declarative parameter mapping configuration - `parse-fossa-params.sh` - Reusable, testable parser script - `test-parse-fossa-params.sh` - Comprehensive test suite (11 tests, all passing) - `README.md` - Complete documentation with examples **Key Improvements:** โœ… JSON-based config - Add parameters without touching bash logic โœ… Self-documenting - Each parameter includes description and example โœ… Testable - Standalone parser script with full test coverage โœ… Safer - Uses indirect expansion instead of eval โœ… Compatible - Works on all systems (no process substitution issues) **Architecture:** ``` User โ†’ additional_scan_params โ†’ Environment Variables โ†“ fossa-params.json (config) + parse-fossa-params.sh (parser) โ†“ FOSSA CLI arguments ``` **Adding New Parameters:** Just add one JSON entry - no code changes needed: ```json { "env": "SCA_FOSSA_NEW_PARAM", "flag": "--new-param", "type": "value", "description": "Description here" } ``` **Test Results:** ``` โœ… All 11 tests passed - Basic flag parameters - Value parameters - Multiple parameters - Empty value handling - Boolean flag handling - Real-world monorepo use case ``` ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/actions/sca/fossa-scan/README.md | 145 ++++++++++++ .github/actions/sca/fossa-scan/action.yaml | 42 +--- .../actions/sca/fossa-scan/fossa-params.json | 69 ++++++ .../sca/fossa-scan/parse-fossa-params.sh | 129 +++++++++++ .../sca/fossa-scan/test-parse-fossa-params.sh | 217 ++++++++++++++++++ 5 files changed, 566 insertions(+), 36 deletions(-) create mode 100644 .github/actions/sca/fossa-scan/README.md create mode 100644 .github/actions/sca/fossa-scan/fossa-params.json create mode 100755 .github/actions/sca/fossa-scan/parse-fossa-params.sh create mode 100755 .github/actions/sca/fossa-scan/test-parse-fossa-params.sh diff --git a/.github/actions/sca/fossa-scan/README.md b/.github/actions/sca/fossa-scan/README.md new file mode 100644 index 0000000..38f95c9 --- /dev/null +++ b/.github/actions/sca/fossa-scan/README.md @@ -0,0 +1,145 @@ +# FOSSA Scan Action + +A GitHub Action that runs FOSSA security and license compliance scanning with configurable parameters. + +## Overview + +This action uses a JSON-based configuration system (`fossa-params.json`) to dynamically map environment variables to FOSSA CLI flags, making it easy to add new parameters without modifying the action logic. + +## Configuration + +### Parameter Mapping (`fossa-params.json`) + +The action reads parameter definitions from `fossa-params.json`: + +```json +{ + "parameters": [ + { + "env": "SCA_FOSSA_CONFIG", + "flag": "--config", + "type": "value", + "description": "Path to custom .fossa.yml configuration file", + "example": "fossa.config=packages/my-package/.fossa.yml" + } + ] +} +``` + +**Field Definitions:** +- `env`: Environment variable name (automatically set by `sca-scan` action) +- `flag`: FOSSA CLI flag to use +- `type`: Either `"flag"` (boolean) or `"value"` (requires a value) +- `description`: Human-readable description +- `example`: Example usage via `additional_scan_params` + +### Parameter Types + +#### Type: `flag` (Boolean) +Only added to CLI if environment variable equals `"true"`. + +**Example:** +```yaml +additional_scan_params: | + fossa.analyze_debug=true +``` +Generates: `fossa analyze --debug` + +#### Type: `value` (String) +Added to CLI with the provided value if non-empty. + +**Example:** +```yaml +additional_scan_params: | + fossa.config=sam-mongodb/.fossa.yml + fossa.path=sam-mongodb +``` +Generates: `fossa analyze --config sam-mongodb/.fossa.yml --path sam-mongodb` + +## Usage + +### Basic Usage + +```yaml +- name: FOSSA Scan + uses: SolaceDev/solace-public-workflows/.github/actions/sca/sca-scan@main + with: + scanners: "fossa" + fossa_api_key: ${{ secrets.FOSSA_API_KEY }} +``` + +### With Custom Parameters + +```yaml +- name: FOSSA Scan (Monorepo Plugin) + uses: SolaceDev/solace-public-workflows/.github/actions/sca/sca-scan@main + with: + scanners: "fossa" + additional_scan_params: | + fossa.path=sam-mongodb + fossa.config=sam-mongodb/.fossa.yml + fossa.project=my-plugin + fossa.branch=PR + fossa.revision=${{ github.sha }} + fossa_api_key: ${{ secrets.FOSSA_API_KEY }} +``` + +## Available Parameters + +| Parameter | Type | FOSSA Flag | Description | +|-----------|------|------------|-------------| +| `fossa.analyze_debug` | flag | `--debug` | Enable debug logging | +| `fossa.branch` | value | `--branch` | Branch name for tracking | +| `fossa.revision` | value | `--revision` | Git commit SHA | +| `fossa.path` | value | `--path` | Base directory to scan | +| `fossa.config` | value | `--config` | Path to `.fossa.yml` | +| `fossa.unpack_archives` | flag | `--unpack-archives` | Unpack and scan archives | +| `fossa.without_default_filters` | flag | `--without-default-filters` | Disable default filters | +| `fossa.force_vendored_dependency_rescans` | flag | `--force-vendored-dependency-rescans` | Force rescan vendored deps | + +See [fossa-params.json](./fossa-params.json) for the complete list with examples. + +## Adding New Parameters + +To add a new FOSSA CLI parameter: + +1. Add an entry to `fossa-params.json`: + ```json + { + "env": "SCA_FOSSA_NEW_PARAM", + "flag": "--new-param", + "type": "value", + "description": "Description of the parameter", + "example": "fossa.new_param=value" + } + ``` + +2. That's it! The action will automatically process it. + +**No code changes required** - the JSON configuration is declarative and self-contained. + +## Architecture + +### Flow Diagram + +``` +User Workflow (sca-scan) + โ†“ + additional_scan_params: "fossa.config=path/.fossa.yml" + โ†“ + Converted to: SCA_FOSSA_CONFIG=path/.fossa.yml + โ†“ +fossa-scan Action + โ†“ + Reads: fossa-params.json + โ†“ + Maps: SCA_FOSSA_CONFIG โ†’ --config path/.fossa.yml + โ†“ + Executes: fossa analyze --config path/.fossa.yml +``` + +## Related Documentation + +- [FOSSA CLI Documentation](https://github.com/fossas/fossa-cli) +- [Parent SCA Scan Action](../sca-scan/) +- [FOSSA Parameter Config](./fossa-params.json) diff --git a/.github/actions/sca/fossa-scan/action.yaml b/.github/actions/sca/fossa-scan/action.yaml index 3859d23..7aabc0c 100644 --- a/.github/actions/sca/fossa-scan/action.yaml +++ b/.github/actions/sca/fossa-scan/action.yaml @@ -12,43 +12,13 @@ runs: echo "Installing FOSSA CLI..." curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash - SCA_FOSSA_ADDITIONAL_ARGS="" + # Use the parameter parser script + export FOSSA_PARAMS_CONFIG="${GITHUB_ACTION_PATH}/fossa-params.json" + source "${GITHUB_ACTION_PATH}/parse-fossa-params.sh" + build_fossa_args - # Define parameter mappings: ENV_VAR_NAME:CLI_FLAG:VALUE_TYPE - # VALUE_TYPE can be: "flag" (boolean flag), "value" (flag with value) - FOSSA_PARAMS=( - "SCA_FOSSA_ANALYZE_DEBUG:--debug:flag" - "SCA_FOSSA_BRANCH:--branch:value" - "SCA_FOSSA_REVISION:--revision:value" - "SCA_FOSSA_PATH:--path:value" - "SCA_FOSSA_CONFIG:--config:value" - "SCA_FOSSA_UNPACK_ARCHIVES:--unpack-archives:flag" - "SCA_FOSSA_WITHOUT_DEFAULT_FILTERS:--without-default-filters:flag" - "SCA_FOSSA_FORCE_VENDORED_DEPENDENCY_RESCANS:--force-vendored-dependency-rescans:flag" - ) - - # Process each parameter - for param in "${FOSSA_PARAMS[@]}"; do - IFS=':' read -r env_var cli_flag value_type <<< "$param" - - # Get the environment variable value - env_value="${!env_var}" - - if [ "$value_type" == "flag" ]; then - # Boolean flag - only add if set to "true" - if [ "$env_value" == "true" ]; then - SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS $cli_flag" - fi - elif [ "$value_type" == "value" ]; then - # Flag with value - only add if value is non-empty - if [ -n "$env_value" ]; then - SCA_FOSSA_ADDITIONAL_ARGS="$SCA_FOSSA_ADDITIONAL_ARGS $cli_flag $env_value" - echo "Using FOSSA $cli_flag: $env_value" - fi - fi - done - - echo "SCA_FOSSA_ADDITIONAL_ARGS=${SCA_FOSSA_ADDITIONAL_ARGS}" >> "$GITHUB_ENV" + # Store result for later steps + echo "SCA_FOSSA_ADDITIONAL_ARGS=${FOSSA_CLI_ARGS}" >> "$GITHUB_ENV" # Set up test args with only revision parameter SCA_FOSSA_TEST_ARGS="" diff --git a/.github/actions/sca/fossa-scan/fossa-params.json b/.github/actions/sca/fossa-scan/fossa-params.json new file mode 100644 index 0000000..3a834cb --- /dev/null +++ b/.github/actions/sca/fossa-scan/fossa-params.json @@ -0,0 +1,69 @@ +{ + "$schema": "fossa-params-schema", + "description": "FOSSA CLI parameter mappings for the fossa-scan GitHub Action", + "version": "1.0.0", + "parameters": [ + { + "env": "SCA_FOSSA_ANALYZE_DEBUG", + "flag": "--debug", + "type": "flag", + "description": "Enable debug logging during FOSSA analysis", + "example": "fossa.analyze_debug=true" + }, + { + "env": "SCA_FOSSA_BRANCH", + "flag": "--branch", + "type": "value", + "description": "Branch name for FOSSA project tracking", + "example": "fossa.branch=main" + }, + { + "env": "SCA_FOSSA_REVISION", + "flag": "--revision", + "type": "value", + "description": "Git revision/commit SHA for FOSSA tracking", + "example": "fossa.revision=abc123" + }, + { + "env": "SCA_FOSSA_PATH", + "flag": "--path", + "type": "value", + "description": "Base directory to scan (useful for monorepos)", + "example": "fossa.path=packages/my-package" + }, + { + "env": "SCA_FOSSA_CONFIG", + "flag": "--config", + "type": "value", + "description": "Path to custom .fossa.yml configuration file", + "example": "fossa.config=packages/my-package/.fossa.yml" + }, + { + "env": "SCA_FOSSA_UNPACK_ARCHIVES", + "flag": "--unpack-archives", + "type": "flag", + "description": "Unpack and scan archive files", + "example": "fossa.unpack_archives=true" + }, + { + "env": "SCA_FOSSA_WITHOUT_DEFAULT_FILTERS", + "flag": "--without-default-filters", + "type": "flag", + "description": "Disable default file filters", + "example": "fossa.without_default_filters=true" + }, + { + "env": "SCA_FOSSA_FORCE_VENDORED_DEPENDENCY_RESCANS", + "flag": "--force-vendored-dependency-rescans", + "type": "flag", + "description": "Force rescanning of vendored dependencies", + "example": "fossa.force_vendored_dependency_rescans=true" + } + ], + "notes": [ + "Parameters are mapped from additional_scan_params (e.g., 'fossa.branch=main') to environment variables (e.g., 'SCA_FOSSA_BRANCH')", + "Type 'flag' means boolean - only added if set to 'true'", + "Type 'value' means the parameter requires a value and is added if non-empty", + "To add a new parameter: add an entry to this file and it will automatically be processed" + ] +} diff --git a/.github/actions/sca/fossa-scan/parse-fossa-params.sh b/.github/actions/sca/fossa-scan/parse-fossa-params.sh new file mode 100755 index 0000000..dd8b7dc --- /dev/null +++ b/.github/actions/sca/fossa-scan/parse-fossa-params.sh @@ -0,0 +1,129 @@ +#!/bin/bash +set -euo pipefail + +############################################################################### +# FOSSA Parameter Parser +# +# Reads fossa-params.json and builds CLI arguments from environment variables. +# +# Usage: +# source parse-fossa-params.sh +# build_fossa_args +# echo "$FOSSA_CLI_ARGS" +# +# Environment: +# FOSSA_PARAMS_CONFIG - Path to fossa-params.json (default: ./fossa-params.json) +# SCA_FOSSA_* - Various FOSSA configuration variables +# +# Output: +# FOSSA_CLI_ARGS - Space-separated CLI arguments for FOSSA +############################################################################### + +# Default configuration file path +FOSSA_PARAMS_CONFIG="${FOSSA_PARAMS_CONFIG:-$(dirname "${BASH_SOURCE[0]}")/fossa-params.json}" + +############################################################################### +# build_fossa_args +# +# Reads JSON configuration and builds FOSSA CLI arguments from environment +# variables. Sets the FOSSA_CLI_ARGS variable with the result. +# +# Returns: +# 0 on success, 1 on error +############################################################################### +build_fossa_args() { + local config_file="$FOSSA_PARAMS_CONFIG" + + # Validate config file exists + if [ ! -f "$config_file" ]; then + echo "โŒ Error: FOSSA parameters config not found: $config_file" >&2 + return 1 + fi + + # Validate JSON syntax + if ! jq empty "$config_file" 2>/dev/null; then + echo "โŒ Error: Invalid JSON in $config_file" >&2 + return 1 + fi + + echo "๐Ÿ“‹ Loading FOSSA parameter mappings from: $config_file" + + # Initialize output variable + FOSSA_CLI_ARGS="" + + # Parse JSON and process each parameter + # Use jq to iterate and output shell-safe commands + local param_count + param_count=$(jq -r '.parameters | length' "$config_file") + + for ((i=0; i&2 + ;; + esac + done + + # Trim leading whitespace + FOSSA_CLI_ARGS="${FOSSA_CLI_ARGS# }" + + echo "โœ… Built FOSSA CLI args: $FOSSA_CLI_ARGS" + + # Export for use in calling scripts + export FOSSA_CLI_ARGS + + return 0 +} + +############################################################################### +# print_fossa_config +# +# Pretty-prints the FOSSA parameter configuration for debugging. +############################################################################### +print_fossa_config() { + local config_file="$FOSSA_PARAMS_CONFIG" + + if [ ! -f "$config_file" ]; then + echo "โŒ Error: Config file not found: $config_file" >&2 + return 1 + fi + + echo "๐Ÿ“‹ FOSSA Parameter Configuration" + echo "================================" + echo "" + + jq -r '.parameters[] | " \(.env)\n Flag: \(.flag)\n Type: \(.type)\n Desc: \(.description)\n Example: \(.example)\n"' "$config_file" +} + +############################################################################### +# If script is executed directly (not sourced), run build_fossa_args +############################################################################### +if [ "${BASH_SOURCE[0]}" == "${0}" ]; then + build_fossa_args "$@" +fi diff --git a/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh b/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh new file mode 100755 index 0000000..47fedbc --- /dev/null +++ b/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh @@ -0,0 +1,217 @@ +#!/bin/bash +set -euo pipefail + +############################################################################### +# Test Suite for parse-fossa-params.sh +# +# Usage: +# ./test-parse-fossa-params.sh +############################################################################### + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +TEST_PASSED=0 +TEST_FAILED=0 + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color + +############################################################################### +# Test Helper Functions +############################################################################### + +assert_equals() { + local expected="$1" + local actual="$2" + local test_name="$3" + + if [ "$expected" == "$actual" ]; then + echo -e "${GREEN}โœ“${NC} $test_name" + ((TEST_PASSED++)) + return 0 + else + echo -e "${RED}โœ—${NC} $test_name" + echo " Expected: $expected" + echo " Actual: $actual" + ((TEST_FAILED++)) + return 1 + fi +} + +assert_contains() { + local haystack="$1" + local needle="$2" + local test_name="$3" + + if [[ "$haystack" == *"$needle"* ]]; then + echo -e "${GREEN}โœ“${NC} $test_name" + ((TEST_PASSED++)) + return 0 + else + echo -e "${RED}โœ—${NC} $test_name" + echo " Expected to contain: $needle" + echo " Actual: $haystack" + ((TEST_FAILED++)) + return 1 + fi +} + +############################################################################### +# Test Cases +############################################################################### + +test_basic_flag_parameter() { + echo "" + echo "Test: Basic flag parameter" + + export SCA_FOSSA_ANALYZE_DEBUG="true" + export FOSSA_PARAMS_CONFIG="$SCRIPT_DIR/fossa-params.json" + + source "$SCRIPT_DIR/parse-fossa-params.sh" + build_fossa_args > /dev/null + + assert_contains "$FOSSA_CLI_ARGS" "--debug" "Should include --debug flag" + + unset SCA_FOSSA_ANALYZE_DEBUG + unset FOSSA_CLI_ARGS +} + +test_value_parameter() { + echo "" + echo "Test: Value parameter" + + export SCA_FOSSA_BRANCH="main" + export FOSSA_PARAMS_CONFIG="$SCRIPT_DIR/fossa-params.json" + + source "$SCRIPT_DIR/parse-fossa-params.sh" + build_fossa_args > /dev/null + + assert_contains "$FOSSA_CLI_ARGS" "--branch main" "Should include --branch with value" + + unset SCA_FOSSA_BRANCH + unset FOSSA_CLI_ARGS +} + +test_multiple_parameters() { + echo "" + echo "Test: Multiple parameters" + + export SCA_FOSSA_ANALYZE_DEBUG="true" + export SCA_FOSSA_BRANCH="PR" + export SCA_FOSSA_REVISION="abc123" + export SCA_FOSSA_PATH="sam-mongodb" + export SCA_FOSSA_CONFIG="sam-mongodb/.fossa.yml" + export FOSSA_PARAMS_CONFIG="$SCRIPT_DIR/fossa-params.json" + + source "$SCRIPT_DIR/parse-fossa-params.sh" + build_fossa_args > /dev/null + + assert_contains "$FOSSA_CLI_ARGS" "--debug" "Should include --debug" + assert_contains "$FOSSA_CLI_ARGS" "--branch PR" "Should include --branch PR" + assert_contains "$FOSSA_CLI_ARGS" "--revision abc123" "Should include --revision" + assert_contains "$FOSSA_CLI_ARGS" "--path sam-mongodb" "Should include --path" + assert_contains "$FOSSA_CLI_ARGS" "--config sam-mongodb/.fossa.yml" "Should include --config" + + unset SCA_FOSSA_ANALYZE_DEBUG SCA_FOSSA_BRANCH SCA_FOSSA_REVISION SCA_FOSSA_PATH SCA_FOSSA_CONFIG + unset FOSSA_CLI_ARGS +} + +test_empty_value_not_included() { + echo "" + echo "Test: Empty value parameter not included" + + export SCA_FOSSA_BRANCH="" + export FOSSA_PARAMS_CONFIG="$SCRIPT_DIR/fossa-params.json" + + source "$SCRIPT_DIR/parse-fossa-params.sh" + build_fossa_args > /dev/null + + if [[ "$FOSSA_CLI_ARGS" == *"--branch"* ]]; then + echo -e "${RED}โœ—${NC} Should not include --branch when value is empty" + echo " Actual: $FOSSA_CLI_ARGS" + ((TEST_FAILED++)) + else + echo -e "${GREEN}โœ“${NC} Should not include --branch when value is empty" + ((TEST_PASSED++)) + fi + + unset SCA_FOSSA_BRANCH + unset FOSSA_CLI_ARGS +} + +test_false_flag_not_included() { + echo "" + echo "Test: False flag parameter not included" + + export SCA_FOSSA_ANALYZE_DEBUG="false" + export FOSSA_PARAMS_CONFIG="$SCRIPT_DIR/fossa-params.json" + + source "$SCRIPT_DIR/parse-fossa-params.sh" + build_fossa_args > /dev/null + + if [[ "$FOSSA_CLI_ARGS" == *"--debug"* ]]; then + echo -e "${RED}โœ—${NC} Should not include --debug when set to false" + echo " Actual: $FOSSA_CLI_ARGS" + ((TEST_FAILED++)) + else + echo -e "${GREEN}โœ“${NC} Should not include --debug when set to false" + ((TEST_PASSED++)) + fi + + unset SCA_FOSSA_ANALYZE_DEBUG + unset FOSSA_CLI_ARGS +} + +test_monorepo_use_case() { + echo "" + echo "Test: Monorepo use case (real-world scenario)" + + export SCA_FOSSA_PATH="sam-mongodb" + export SCA_FOSSA_CONFIG="sam-mongodb/.fossa.yml" + export SCA_FOSSA_PROJECT="SolaceLabs_sam-mongodb" + export SCA_FOSSA_BRANCH="PR" + export SCA_FOSSA_REVISION="feature-branch" + export FOSSA_PARAMS_CONFIG="$SCRIPT_DIR/fossa-params.json" + + source "$SCRIPT_DIR/parse-fossa-params.sh" + build_fossa_args > /dev/null + + assert_contains "$FOSSA_CLI_ARGS" "--path sam-mongodb" "Should include plugin path" + assert_contains "$FOSSA_CLI_ARGS" "--config sam-mongodb/.fossa.yml" "Should include plugin config" + + unset SCA_FOSSA_PATH SCA_FOSSA_CONFIG SCA_FOSSA_PROJECT SCA_FOSSA_BRANCH SCA_FOSSA_REVISION + unset FOSSA_CLI_ARGS +} + +############################################################################### +# Run All Tests +############################################################################### + +echo "=================================================" +echo "๐Ÿงช FOSSA Parameter Parser Test Suite" +echo "=================================================" + +test_basic_flag_parameter +test_value_parameter +test_multiple_parameters +test_empty_value_not_included +test_false_flag_not_included +test_monorepo_use_case + +echo "" +echo "=================================================" +echo "๐Ÿ“Š Test Results" +echo "=================================================" +echo -e "${GREEN}Passed:${NC} $TEST_PASSED" +echo -e "${RED}Failed:${NC} $TEST_FAILED" +echo "=================================================" + +if [ $TEST_FAILED -eq 0 ]; then + echo -e "${GREEN}โœ… All tests passed!${NC}" + exit 0 +else + echo -e "${RED}โŒ Some tests failed${NC}" + exit 1 +fi From c1cf6f92fb428c2d856eadd5d8430db012a0b3b5 Mon Sep 17 00:00:00 2001 From: John Corpuz Date: Mon, 22 Dec 2025 12:59:16 -0500 Subject: [PATCH 04/13] docs: Add comprehensive contribution guide for adding new parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Step-by-step instructions for adding parameters - Test suite execution requirements - Optional test case creation guide - Field-by-field JSON configuration guide ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/actions/sca/fossa-scan/README.md | 91 +++++++++++++++++++----- 1 file changed, 75 insertions(+), 16 deletions(-) diff --git a/.github/actions/sca/fossa-scan/README.md b/.github/actions/sca/fossa-scan/README.md index 38f95c9..8eca17e 100644 --- a/.github/actions/sca/fossa-scan/README.md +++ b/.github/actions/sca/fossa-scan/README.md @@ -101,22 +101,81 @@ See [fossa-params.json](./fossa-params.json) for the complete list with examples ## Adding New Parameters -To add a new FOSSA CLI parameter: - -1. Add an entry to `fossa-params.json`: - ```json - { - "env": "SCA_FOSSA_NEW_PARAM", - "flag": "--new-param", - "type": "value", - "description": "Description of the parameter", - "example": "fossa.new_param=value" - } - ``` - -2. That's it! The action will automatically process it. - -**No code changes required** - the JSON configuration is declarative and self-contained. +To add a new FOSSA CLI parameter, follow these steps: + +### 1. Update the JSON Configuration + +Add an entry to [`fossa-params.json`](./fossa-params.json): + +```json +{ + "env": "SCA_FOSSA_NEW_PARAM", + "flag": "--new-param", + "type": "value", + "description": "Description of what this parameter does", + "example": "fossa.new_param=value" +} +``` + +**Field Guide:** +- `env`: Environment variable name (must start with `SCA_FOSSA_`) +- `flag`: FOSSA CLI flag (e.g., `--config`, `--path`) +- `type`: Either `"flag"` (boolean) or `"value"` (requires a value) +- `description`: Human-readable description of the parameter +- `example`: Usage example via `additional_scan_params` + +### 2. Run the Test Suite + +Before committing, verify your changes work correctly: + +```bash +cd .github/actions/sca/fossa-scan +./test-parse-fossa-params.sh +``` + +Expected output: +``` +๐Ÿงช FOSSA Parameter Parser Test Suite +... +โœ… All tests passed! +``` + +### 3. (Optional) Add a Test Case + +For complex parameters, add a test case to [`test-parse-fossa-params.sh`](./test-parse-fossa-params.sh): + +```bash +test_your_new_parameter() { + echo "" + echo "Test: Your new parameter" + + export SCA_FOSSA_NEW_PARAM="test-value" + export FOSSA_PARAMS_CONFIG="$SCRIPT_DIR/fossa-params.json" + + source "$SCRIPT_DIR/parse-fossa-params.sh" + build_fossa_args > /dev/null + + assert_contains "$FOSSA_CLI_ARGS" "--new-param test-value" \ + "Should include --new-param with value" + + unset SCA_FOSSA_NEW_PARAM FOSSA_CLI_ARGS +} +``` + +Then add `test_your_new_parameter` to the test execution section. + +### 4. Update Documentation + +Add your parameter to the "Available Parameters" table in this README. + +### 5. Commit and Create PR + +```bash +git add fossa-params.json README.md +git commit -m "feat: Add support for --new-param FOSSA flag" +``` + +**That's it!** No code changes to `action.yaml` or `parse-fossa-params.sh` are needed - the JSON configuration is declarative and self-contained. ## Architecture From 8003653a3ececb0b4ad5416140f36333dc8a26e3 Mon Sep 17 00:00:00 2001 From: John Corpuz Date: Mon, 22 Dec 2025 13:02:04 -0500 Subject: [PATCH 05/13] docs: Add comprehensive README for sca-scan action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Complete documentation covering: - Overview and architecture - Input parameters and usage examples - Parameter conversion system - Monorepo and matrix build examples - Error handling and troubleshooting - Extension guide for adding new scanners ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/actions/sca/sca-scan/README.md | 256 +++++++++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 .github/actions/sca/sca-scan/README.md diff --git a/.github/actions/sca/sca-scan/README.md b/.github/actions/sca/sca-scan/README.md new file mode 100644 index 0000000..eada7c0 --- /dev/null +++ b/.github/actions/sca/sca-scan/README.md @@ -0,0 +1,256 @@ +# SCA Scan Action + +A generic Software Composition Analysis (SCA) scan entrypoint that orchestrates multiple security scanning tools. + +## Overview + +This action serves as a unified interface for running various SCA scanners (currently supporting FOSSA). It handles parameter conversion and routing to specific scanner implementations. + +## Features + +- **Multi-scanner support**: Run one or more SCA scanners (currently: FOSSA) +- **Unified parameter system**: Configure scanner-specific options through `additional_scan_params` +- **Automatic parameter conversion**: Converts `scanner.param_name` โ†’ `SCA_SCANNER_PARAM_NAME` environment variables +- **Extensible architecture**: Easy to add new scanners without changing caller workflows + +## Usage + +### Basic Usage + +```yaml +- name: Run SCA Scan + uses: SolaceDev/solace-public-workflows/.github/actions/sca/sca-scan@main + with: + scanners: "fossa" + fossa_api_key: ${{ secrets.FOSSA_API_KEY }} +``` + +### With Custom Parameters + +```yaml +- name: Run SCA Scan with Custom Config + uses: SolaceDev/solace-public-workflows/.github/actions/sca/sca-scan@main + with: + scanners: "fossa" + additional_scan_params: | + fossa.path=packages/my-package + fossa.config=packages/my-package/.fossa.yml + fossa.branch=main + fossa.revision=${{ github.sha }} + fossa_api_key: ${{ secrets.FOSSA_API_KEY }} +``` + +### Monorepo Use Case + +```yaml +- name: Scan Specific Plugin + uses: SolaceDev/solace-public-workflows/.github/actions/sca/sca-scan@main + with: + scanners: "fossa" + additional_scan_params: | + fossa.path=sam-mongodb + fossa.config=sam-mongodb/.fossa.yml + fossa.project=SolaceLabs_sam-mongodb + fossa.branch=PR + fossa_api_key: ${{ secrets.FOSSA_API_KEY }} +``` + +## Inputs + +| Input | Description | Required | Default | +|-------|-------------|----------|---------| +| `scanners` | Comma-separated list of scanners to run | No | `"fossa"` | +| `additional_scan_params` | Scanner-specific parameters (see below) | No | `""` | +| `fossa_api_key` | API key for FOSSA scanner | No (required if using FOSSA) | `""` | + +## Additional Scan Parameters + +The `additional_scan_params` input accepts scanner-specific configuration in `scanner.param_name=value` format. + +### Format + +```yaml +additional_scan_params: | + scanner.parameter_name=value + scanner.another_param=another_value +``` + +### Parameter Conversion + +Parameters are automatically converted to environment variables: + +| Input Format | Environment Variable | Example | +|--------------|---------------------|---------| +| `fossa.config` | `SCA_FOSSA_CONFIG` | `fossa.config=.fossa.yml` โ†’ `SCA_FOSSA_CONFIG=.fossa.yml` | +| `fossa.branch` | `SCA_FOSSA_BRANCH` | `fossa.branch=main` โ†’ `SCA_FOSSA_BRANCH=main` | +| `fossa.analyze_debug` | `SCA_FOSSA_ANALYZE_DEBUG` | `fossa.analyze_debug=true` โ†’ `SCA_FOSSA_ANALYZE_DEBUG=true` | + +**Conversion Rules:** +1. Prefix with `SCA_` +2. Replace `.` with `_` +3. Convert to UPPERCASE + +### Comments and Empty Lines + +```yaml +additional_scan_params: | + # This is a comment - will be ignored + fossa.branch=main + + # Empty lines are also ignored + fossa.config=.fossa.yml +``` + +### Available Parameters by Scanner + +#### FOSSA + +See the [FOSSA Scan Action README](../fossa-scan/README.md) for a complete list of available parameters. + +**Common FOSSA Parameters:** +- `fossa.path` - Base directory to scan +- `fossa.config` - Path to `.fossa.yml` configuration file +- `fossa.branch` - Branch name for tracking +- `fossa.revision` - Git commit SHA +- `fossa.project` - Custom project name +- `fossa.analyze_debug` - Enable debug logging (`true`/`false`) + +## How It Works + +### Architecture Flow + +``` +User Workflow + โ†“ + sca-scan Action + โ†“ + Parse additional_scan_params + โ†“ + Convert to Environment Variables + (fossa.config โ†’ SCA_FOSSA_CONFIG) + โ†“ + Route to Scanner Action (fossa-scan) + โ†“ + Scanner reads SCA_* environment variables + โ†“ + Execute Scanner CLI +``` + +### Parameter Parsing + +1. **Input**: Multi-line string with `key=value` pairs +2. **Parsing**: Split on `=`, trim whitespace +3. **Conversion**: Apply naming convention (`SCA_SCANNER_PARAM`) +4. **Export**: Set as environment variable in `$GITHUB_ENV` +5. **Propagation**: Available to all child actions + +### Example Transformation + +**Input:** +```yaml +additional_scan_params: | + fossa.path=sam-mongodb + fossa.config=sam-mongodb/.fossa.yml +``` + +**Exported Variables:** +```bash +SCA_FOSSA_PATH=sam-mongodb +SCA_FOSSA_CONFIG=sam-mongodb/.fossa.yml +``` + +**FOSSA Command:** +```bash +fossa analyze --path sam-mongodb --config sam-mongodb/.fossa.yml +``` + +## Error Handling + +### Invalid Parameter Format + +```yaml +additional_scan_params: | + invalid_line_without_equals +``` + +**Result:** +``` +โŒ Invalid additional_scan_params line (missing '='): invalid_line_without_equals +``` + +The action will fail fast to prevent incorrect configuration. + +## Extending with New Scanners + +To add a new scanner: + +1. **Create scanner action**: `.github/actions/sca/new-scanner/action.yaml` +2. **Add input**: Add `new_scanner_api_key` input to this action +3. **Add step**: Add routing step to call your scanner action +4. **Update docs**: Document scanner-specific parameters + +**Example:** +```yaml +- name: SCA - Run NewScanner scan + if: contains(inputs.scanners, 'newscanner') + uses: SolaceDev/solace-public-workflows/.github/actions/sca/new-scanner@main + env: + NEWSCANNER_API_KEY: ${{ inputs.newscanner_api_key }} +``` + +## Related Documentation + +- [FOSSA Scan Action](../fossa-scan/README.md) - FOSSA scanner implementation +- [FOSSA Parameters](../fossa-scan/fossa-params.json) - Complete FOSSA parameter list +- [FOSSA CLI Docs](https://github.com/fossas/fossa-cli) - Official FOSSA documentation + +## Troubleshooting + + + +### Matrix Build (Multiple Packages) + +```yaml +jobs: + sca-scan: + strategy: + matrix: + package: [sam-mongodb, sam-slack, sam-jira] + steps: + - name: Scan ${{ matrix.package }} + uses: SolaceDev/solace-public-workflows/.github/actions/sca/sca-scan@main + with: + scanners: "fossa" + additional_scan_params: | + fossa.path=${{ matrix.package }} + fossa.config=${{ matrix.package }}/.fossa.yml + fossa.project=MyOrg_${{ matrix.package }} + fossa_api_key: ${{ secrets.FOSSA_API_KEY }} +``` + +### PR Scanning + +```yaml +- name: Scan PR Changes + uses: SolaceDev/solace-public-workflows/.github/actions/sca/sca-scan@main + with: + scanners: "fossa" + additional_scan_params: | + fossa.branch=PR + fossa.revision=${{ github.event.pull_request.head.sha }} + fossa_api_key: ${{ secrets.FOSSA_API_KEY }} +``` + +### Main Branch Scanning + +```yaml +- name: Scan Main Branch + if: github.ref == 'refs/heads/main' + uses: SolaceDev/solace-public-workflows/.github/actions/sca/sca-scan@main + with: + scanners: "fossa" + additional_scan_params: | + fossa.branch=${{ github.ref_name }} + fossa.revision=${{ github.sha }} + fossa_api_key: ${{ secrets.FOSSA_API_KEY }} +``` From d4d066a5b38538613fe8fc93c7d1551983665975 Mon Sep 17 00:00:00 2001 From: John Corpuz Date: Mon, 22 Dec 2025 13:29:19 -0500 Subject: [PATCH 06/13] feat: Add support for fossa.project parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds the missing --project flag support to allow overriding the FOSSA project name/ID for better monorepo organization. Changes: - Add SCA_FOSSA_PROJECT โ†’ --project mapping to fossa-params.json - Add test case for project parameter (13 tests now, all passing) - Update README to document fossa.project parameter - Update monorepo test to verify project flag is included Usage: ```yaml additional_scan_params: | fossa.project=MyOrg_my-project fossa.path=my-project fossa.config=my-project/.fossa.yml ``` This will generate: ```bash fossa analyze --project MyOrg_my-project --path my-project --config my-project/.fossa.yml ``` ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/actions/sca/fossa-scan/README.md | 1 + .../actions/sca/fossa-scan/fossa-params.json | 7 +++++++ .../sca/fossa-scan/test-parse-fossa-params.sh | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/.github/actions/sca/fossa-scan/README.md b/.github/actions/sca/fossa-scan/README.md index 8eca17e..0502ed9 100644 --- a/.github/actions/sca/fossa-scan/README.md +++ b/.github/actions/sca/fossa-scan/README.md @@ -91,6 +91,7 @@ Generates: `fossa analyze --config sam-mongodb/.fossa.yml --path sam-mongodb` | `fossa.analyze_debug` | flag | `--debug` | Enable debug logging | | `fossa.branch` | value | `--branch` | Branch name for tracking | | `fossa.revision` | value | `--revision` | Git commit SHA | +| `fossa.project` | value | `--project` | Override project name/ID | | `fossa.path` | value | `--path` | Base directory to scan | | `fossa.config` | value | `--config` | Path to `.fossa.yml` | | `fossa.unpack_archives` | flag | `--unpack-archives` | Unpack and scan archives | diff --git a/.github/actions/sca/fossa-scan/fossa-params.json b/.github/actions/sca/fossa-scan/fossa-params.json index 3a834cb..fff9d6e 100644 --- a/.github/actions/sca/fossa-scan/fossa-params.json +++ b/.github/actions/sca/fossa-scan/fossa-params.json @@ -24,6 +24,13 @@ "description": "Git revision/commit SHA for FOSSA tracking", "example": "fossa.revision=abc123" }, + { + "env": "SCA_FOSSA_PROJECT", + "flag": "--project", + "type": "value", + "description": "Override project name/ID for FOSSA tracking", + "example": "fossa.project=MyOrg_my-project" + }, { "env": "SCA_FOSSA_PATH", "flag": "--path", diff --git a/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh b/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh index 47fedbc..baae609 100755 --- a/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh +++ b/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh @@ -164,6 +164,22 @@ test_false_flag_not_included() { unset FOSSA_CLI_ARGS } +test_project_parameter() { + echo "" + echo "Test: Project parameter" + + export SCA_FOSSA_PROJECT="MyOrg_my-project" + export FOSSA_PARAMS_CONFIG="$SCRIPT_DIR/fossa-params.json" + + source "$SCRIPT_DIR/parse-fossa-params.sh" + build_fossa_args > /dev/null + + assert_contains "$FOSSA_CLI_ARGS" "--project MyOrg_my-project" "Should include project override" + + unset SCA_FOSSA_PROJECT + unset FOSSA_CLI_ARGS +} + test_monorepo_use_case() { echo "" echo "Test: Monorepo use case (real-world scenario)" @@ -178,6 +194,7 @@ test_monorepo_use_case() { source "$SCRIPT_DIR/parse-fossa-params.sh" build_fossa_args > /dev/null + assert_contains "$FOSSA_CLI_ARGS" "--project SolaceLabs_sam-mongodb" "Should include project name" assert_contains "$FOSSA_CLI_ARGS" "--path sam-mongodb" "Should include plugin path" assert_contains "$FOSSA_CLI_ARGS" "--config sam-mongodb/.fossa.yml" "Should include plugin config" @@ -198,6 +215,7 @@ test_value_parameter test_multiple_parameters test_empty_value_not_included test_false_flag_not_included +test_project_parameter test_monorepo_use_case echo "" From 9e2074b55d4ae87db38760a72b5f7770c34fc2d3 Mon Sep 17 00:00:00 2001 From: John Corpuz Date: Mon, 22 Dec 2025 13:41:15 -0500 Subject: [PATCH 07/13] feat: Add command-specific parameter filtering for fossa test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements intelligent parameter filtering so 'fossa test' only receives parameters it supports, while 'fossa analyze' gets all parameters. **Changes:** Schema Update (fossa-params.json v2.0.0): - Add 'commands' field to each parameter: ['analyze'] or ['analyze', 'test'] - Documents which FOSSA commands support each parameter - Shared parameters: branch, revision, project, config - Analyze-only: debug, path, unpack_archives, without_default_filters, force_vendored_dependency_rescans Parser Enhancement (parse-fossa-params.sh): - Add optional 'command' parameter to build_fossa_args() - Filter parameters based on commands array in JSON - Usage: `build_fossa_args "analyze"` or `build_fossa_args "test"` Action Update (action.yaml): - Build separate args for analyze and test commands - Replaces hardcoded test args logic with parser Test Coverage (test-parse-fossa-params.sh): - Add test_command_filtering_analyze() - 3 assertions - Add test_command_filtering_test() - 6 assertions - Verify analyze-only params excluded from test command - **22 tests total, all passing** โœ… **Before:** ```bash # Test args were hardcoded, only supported --revision SCA_FOSSA_TEST_ARGS="--revision ${SCA_FOSSA_REVISION}" ``` **After:** ```bash # Test args built dynamically from same config build_fossa_args "test" # Gets: --branch, --revision, --project, --config build_fossa_args "analyze" # Gets: all parameters including --path, --debug ``` ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/actions/sca/fossa-scan/action.yaml | 15 ++--- .../actions/sca/fossa-scan/fossa-params.json | 12 +++- .../sca/fossa-scan/parse-fossa-params.sh | 24 ++++++- .../sca/fossa-scan/test-parse-fossa-params.sh | 64 +++++++++++++++++++ 4 files changed, 102 insertions(+), 13 deletions(-) diff --git a/.github/actions/sca/fossa-scan/action.yaml b/.github/actions/sca/fossa-scan/action.yaml index 7aabc0c..6fe86ce 100644 --- a/.github/actions/sca/fossa-scan/action.yaml +++ b/.github/actions/sca/fossa-scan/action.yaml @@ -12,20 +12,17 @@ runs: echo "Installing FOSSA CLI..." curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/master/install-latest.sh | bash - # Use the parameter parser script + # Use the parameter parser script for analyze command export FOSSA_PARAMS_CONFIG="${GITHUB_ACTION_PATH}/fossa-params.json" source "${GITHUB_ACTION_PATH}/parse-fossa-params.sh" - build_fossa_args - # Store result for later steps + # Build analyze args + build_fossa_args "analyze" echo "SCA_FOSSA_ADDITIONAL_ARGS=${FOSSA_CLI_ARGS}" >> "$GITHUB_ENV" - # Set up test args with only revision parameter - SCA_FOSSA_TEST_ARGS="" - if [ -n "${{ env.SCA_FOSSA_REVISION }}" ]; then - SCA_FOSSA_TEST_ARGS="--revision ${{ env.SCA_FOSSA_REVISION }}" - fi - echo "SCA_FOSSA_TEST_ARGS=${SCA_FOSSA_TEST_ARGS}" >> "$GITHUB_ENV" + # Build test args + build_fossa_args "test" + echo "SCA_FOSSA_TEST_ARGS=${FOSSA_CLI_ARGS}" >> "$GITHUB_ENV" echo "::endgroup::" diff --git a/.github/actions/sca/fossa-scan/fossa-params.json b/.github/actions/sca/fossa-scan/fossa-params.json index fff9d6e..a7eca04 100644 --- a/.github/actions/sca/fossa-scan/fossa-params.json +++ b/.github/actions/sca/fossa-scan/fossa-params.json @@ -1,12 +1,13 @@ { "$schema": "fossa-params-schema", "description": "FOSSA CLI parameter mappings for the fossa-scan GitHub Action", - "version": "1.0.0", + "version": "2.0.0", "parameters": [ { "env": "SCA_FOSSA_ANALYZE_DEBUG", "flag": "--debug", "type": "flag", + "commands": ["analyze"], "description": "Enable debug logging during FOSSA analysis", "example": "fossa.analyze_debug=true" }, @@ -14,6 +15,7 @@ "env": "SCA_FOSSA_BRANCH", "flag": "--branch", "type": "value", + "commands": ["analyze", "test"], "description": "Branch name for FOSSA project tracking", "example": "fossa.branch=main" }, @@ -21,6 +23,7 @@ "env": "SCA_FOSSA_REVISION", "flag": "--revision", "type": "value", + "commands": ["analyze", "test"], "description": "Git revision/commit SHA for FOSSA tracking", "example": "fossa.revision=abc123" }, @@ -28,6 +31,7 @@ "env": "SCA_FOSSA_PROJECT", "flag": "--project", "type": "value", + "commands": ["analyze", "test"], "description": "Override project name/ID for FOSSA tracking", "example": "fossa.project=MyOrg_my-project" }, @@ -35,6 +39,7 @@ "env": "SCA_FOSSA_PATH", "flag": "--path", "type": "value", + "commands": ["analyze"], "description": "Base directory to scan (useful for monorepos)", "example": "fossa.path=packages/my-package" }, @@ -42,6 +47,7 @@ "env": "SCA_FOSSA_CONFIG", "flag": "--config", "type": "value", + "commands": ["analyze", "test"], "description": "Path to custom .fossa.yml configuration file", "example": "fossa.config=packages/my-package/.fossa.yml" }, @@ -49,6 +55,7 @@ "env": "SCA_FOSSA_UNPACK_ARCHIVES", "flag": "--unpack-archives", "type": "flag", + "commands": ["analyze"], "description": "Unpack and scan archive files", "example": "fossa.unpack_archives=true" }, @@ -56,6 +63,7 @@ "env": "SCA_FOSSA_WITHOUT_DEFAULT_FILTERS", "flag": "--without-default-filters", "type": "flag", + "commands": ["analyze"], "description": "Disable default file filters", "example": "fossa.without_default_filters=true" }, @@ -63,6 +71,7 @@ "env": "SCA_FOSSA_FORCE_VENDORED_DEPENDENCY_RESCANS", "flag": "--force-vendored-dependency-rescans", "type": "flag", + "commands": ["analyze"], "description": "Force rescanning of vendored dependencies", "example": "fossa.force_vendored_dependency_rescans=true" } @@ -71,6 +80,7 @@ "Parameters are mapped from additional_scan_params (e.g., 'fossa.branch=main') to environment variables (e.g., 'SCA_FOSSA_BRANCH')", "Type 'flag' means boolean - only added if set to 'true'", "Type 'value' means the parameter requires a value and is added if non-empty", + "The 'commands' field specifies which FOSSA commands support this parameter: 'analyze' and/or 'test'", "To add a new parameter: add an entry to this file and it will automatically be processed" ] } diff --git a/.github/actions/sca/fossa-scan/parse-fossa-params.sh b/.github/actions/sca/fossa-scan/parse-fossa-params.sh index dd8b7dc..00f4572 100755 --- a/.github/actions/sca/fossa-scan/parse-fossa-params.sh +++ b/.github/actions/sca/fossa-scan/parse-fossa-params.sh @@ -23,15 +23,20 @@ set -euo pipefail FOSSA_PARAMS_CONFIG="${FOSSA_PARAMS_CONFIG:-$(dirname "${BASH_SOURCE[0]}")/fossa-params.json}" ############################################################################### -# build_fossa_args +# build_fossa_args [command] # # Reads JSON configuration and builds FOSSA CLI arguments from environment # variables. Sets the FOSSA_CLI_ARGS variable with the result. # +# Parameters: +# command - Optional FOSSA command to filter parameters by (e.g., "analyze", "test") +# If not provided, uses all parameters regardless of command. +# # Returns: # 0 on success, 1 on error ############################################################################### build_fossa_args() { + local filter_command="${1:-}" local config_file="$FOSSA_PARAMS_CONFIG" # Validate config file exists @@ -46,7 +51,11 @@ build_fossa_args() { return 1 fi - echo "๐Ÿ“‹ Loading FOSSA parameter mappings from: $config_file" + if [ -n "$filter_command" ]; then + echo "๐Ÿ“‹ Loading FOSSA '$filter_command' parameter mappings from: $config_file" + else + echo "๐Ÿ“‹ Loading FOSSA parameter mappings from: $config_file" + fi # Initialize output variable FOSSA_CLI_ARGS="" @@ -57,11 +66,20 @@ build_fossa_args() { param_count=$(jq -r '.parameters | length' "$config_file") for ((i=0; i /dev/null + + assert_contains "$FOSSA_CLI_ARGS" "--debug" "Analyze should include --debug" + assert_contains "$FOSSA_CLI_ARGS" "--path sam-mongodb" "Analyze should include --path" + assert_contains "$FOSSA_CLI_ARGS" "--config sam-mongodb/.fossa.yml" "Analyze should include --config" + + unset SCA_FOSSA_ANALYZE_DEBUG SCA_FOSSA_PATH SCA_FOSSA_CONFIG + unset FOSSA_CLI_ARGS +} + +test_command_filtering_test() { + echo "" + echo "Test: Command filtering - test" + + export SCA_FOSSA_ANALYZE_DEBUG="true" + export SCA_FOSSA_PATH="sam-mongodb" + export SCA_FOSSA_CONFIG="sam-mongodb/.fossa.yml" + export SCA_FOSSA_BRANCH="PR" + export SCA_FOSSA_REVISION="abc123" + export SCA_FOSSA_PROJECT="MyOrg_project" + export FOSSA_PARAMS_CONFIG="$SCRIPT_DIR/fossa-params.json" + + source "$SCRIPT_DIR/parse-fossa-params.sh" + build_fossa_args "test" > /dev/null + + # Test command should include these + assert_contains "$FOSSA_CLI_ARGS" "--branch PR" "Test should include --branch" + assert_contains "$FOSSA_CLI_ARGS" "--revision abc123" "Test should include --revision" + assert_contains "$FOSSA_CLI_ARGS" "--project MyOrg_project" "Test should include --project" + assert_contains "$FOSSA_CLI_ARGS" "--config sam-mongodb/.fossa.yml" "Test should include --config" + + # Test command should NOT include these (analyze-only) + if [[ "$FOSSA_CLI_ARGS" == *"--debug"* ]]; then + echo -e "${RED}โœ—${NC} Test should NOT include --debug (analyze-only)" + ((TEST_FAILED++)) + else + echo -e "${GREEN}โœ“${NC} Test should NOT include --debug (analyze-only)" + ((TEST_PASSED++)) + fi + + if [[ "$FOSSA_CLI_ARGS" == *"--path"* ]]; then + echo -e "${RED}โœ—${NC} Test should NOT include --path (analyze-only)" + ((TEST_FAILED++)) + else + echo -e "${GREEN}โœ“${NC} Test should NOT include --path (analyze-only)" + ((TEST_PASSED++)) + fi + + unset SCA_FOSSA_ANALYZE_DEBUG SCA_FOSSA_PATH SCA_FOSSA_CONFIG SCA_FOSSA_BRANCH SCA_FOSSA_REVISION SCA_FOSSA_PROJECT + unset FOSSA_CLI_ARGS +} + test_monorepo_use_case() { echo "" echo "Test: Monorepo use case (real-world scenario)" @@ -216,6 +278,8 @@ test_multiple_parameters test_empty_value_not_included test_false_flag_not_included test_project_parameter +test_command_filtering_analyze +test_command_filtering_test test_monorepo_use_case echo "" From 6ef2d3f37117293a0c352a77e57496e94b303035 Mon Sep 17 00:00:00 2001 From: John Corpuz Date: Mon, 22 Dec 2025 13:44:12 -0500 Subject: [PATCH 08/13] docs: Update README to document command-specific parameters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add Commands column to Available Parameters table - Document which params work with analyze vs test - Update Field Guide with commands array documentation - Explain command filtering behavior ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/actions/sca/fossa-scan/README.md | 32 ++++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/.github/actions/sca/fossa-scan/README.md b/.github/actions/sca/fossa-scan/README.md index 0502ed9..4a86316 100644 --- a/.github/actions/sca/fossa-scan/README.md +++ b/.github/actions/sca/fossa-scan/README.md @@ -86,17 +86,22 @@ Generates: `fossa analyze --config sam-mongodb/.fossa.yml --path sam-mongodb` ## Available Parameters -| Parameter | Type | FOSSA Flag | Description | -|-----------|------|------------|-------------| -| `fossa.analyze_debug` | flag | `--debug` | Enable debug logging | -| `fossa.branch` | value | `--branch` | Branch name for tracking | -| `fossa.revision` | value | `--revision` | Git commit SHA | -| `fossa.project` | value | `--project` | Override project name/ID | -| `fossa.path` | value | `--path` | Base directory to scan | -| `fossa.config` | value | `--config` | Path to `.fossa.yml` | -| `fossa.unpack_archives` | flag | `--unpack-archives` | Unpack and scan archives | -| `fossa.without_default_filters` | flag | `--without-default-filters` | Disable default filters | -| `fossa.force_vendored_dependency_rescans` | flag | `--force-vendored-dependency-rescans` | Force rescan vendored deps | +| Parameter | Type | FOSSA Flag | Commands | Description | +|-----------|------|------------|----------|-------------| +| `fossa.analyze_debug` | flag | `--debug` | `analyze` | Enable debug logging | +| `fossa.branch` | value | `--branch` | `analyze`, `test` | Branch name for tracking | +| `fossa.revision` | value | `--revision` | `analyze`, `test` | Git commit SHA | +| `fossa.project` | value | `--project` | `analyze`, `test` | Override project name/ID | +| `fossa.path` | value | `--path` | `analyze` | Base directory to scan | +| `fossa.config` | value | `--config` | `analyze`, `test` | Path to `.fossa.yml` | +| `fossa.unpack_archives` | flag | `--unpack-archives` | `analyze` | Unpack and scan archives | +| `fossa.without_default_filters` | flag | `--without-default-filters` | `analyze` | Disable default filters | +| `fossa.force_vendored_dependency_rescans` | flag | `--force-vendored-dependency-rescans` | `analyze` | Force rescan vendored deps | + +**Commands Column:** +- `analyze` - Used for the `fossa analyze` command (scans code and uploads results) +- `test` - Used for the `fossa test` command (checks scan results against policies) +- Both commands - Parameter is used by both commands See [fossa-params.json](./fossa-params.json) for the complete list with examples. @@ -113,6 +118,7 @@ Add an entry to [`fossa-params.json`](./fossa-params.json): "env": "SCA_FOSSA_NEW_PARAM", "flag": "--new-param", "type": "value", + "commands": ["analyze", "test"], "description": "Description of what this parameter does", "example": "fossa.new_param=value" } @@ -122,6 +128,10 @@ Add an entry to [`fossa-params.json`](./fossa-params.json): - `env`: Environment variable name (must start with `SCA_FOSSA_`) - `flag`: FOSSA CLI flag (e.g., `--config`, `--path`) - `type`: Either `"flag"` (boolean) or `"value"` (requires a value) +- `commands`: Array of FOSSA commands that support this parameter + - `["analyze"]` - Only used for `fossa analyze` + - `["test"]` - Only used for `fossa test` + - `["analyze", "test"]` - Used for both commands - `description`: Human-readable description of the parameter - `example`: Usage example via `additional_scan_params` From 8983b16410e5f2259887317e29e012b02b7ad996 Mon Sep 17 00:00:00 2001 From: John Corpuz Date: Mon, 22 Dec 2025 13:45:58 -0500 Subject: [PATCH 09/13] fix: Use relative path for fossa-scan action reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change from absolute @main reference to relative ./fossa-scan path. This ensures the sca-scan action uses the fossa-scan action from the same branch/commit instead of always pulling from main. **Problem:** When using @specify_fossa_config_path branch: - sca-scan action loaded from branch โœ… - fossa-scan action loaded from @main โŒ (old version) - Result: New parameters not applied **Solution:** Use relative path './fossa-scan' so both actions load from same source. **Before:** ```yaml uses: SolaceDev/solace-public-workflows/.github/actions/sca/fossa-scan@main ``` **After:** ```yaml uses: ./fossa-scan # Relative path from sca-scan directory ``` This is the standard pattern for composite actions referencing local actions. ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/actions/sca/sca-scan/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/sca/sca-scan/action.yaml b/.github/actions/sca/sca-scan/action.yaml index 491a7e7..bbe5028 100644 --- a/.github/actions/sca/sca-scan/action.yaml +++ b/.github/actions/sca/sca-scan/action.yaml @@ -66,6 +66,6 @@ runs: - name: SCA - Run Fossa scan if: contains(inputs.scanners, 'fossa') - uses: SolaceDev/solace-public-workflows/.github/actions/sca/fossa-scan@main + uses: ./fossa-scan env: FOSSA_API_KEY: ${{ inputs.fossa_api_key }} From 0c5009b7d929548650e97c4c66300f6d9e5c8578 Mon Sep 17 00:00:00 2001 From: John Corpuz Date: Mon, 22 Dec 2025 13:50:08 -0500 Subject: [PATCH 10/13] fix: Use branch reference for fossa-scan during testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use @specify_fossa_config_path branch reference to test changes. This will be changed back to @main before merging. ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/actions/sca/sca-scan/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/sca/sca-scan/action.yaml b/.github/actions/sca/sca-scan/action.yaml index bbe5028..2dce492 100644 --- a/.github/actions/sca/sca-scan/action.yaml +++ b/.github/actions/sca/sca-scan/action.yaml @@ -66,6 +66,6 @@ runs: - name: SCA - Run Fossa scan if: contains(inputs.scanners, 'fossa') - uses: ./fossa-scan + uses: SolaceDev/solace-public-workflows/.github/actions/sca/fossa-scan@specify_fossa_config_path env: FOSSA_API_KEY: ${{ inputs.fossa_api_key }} From b99dffe90732f080d59cf0d897b00a1400b333b5 Mon Sep 17 00:00:00 2001 From: John Corpuz Date: Mon, 22 Dec 2025 14:00:57 -0500 Subject: [PATCH 11/13] fix: Use working-directory instead of non-existent --path flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FOSSA CLI doesn't have a --path flag. Instead, use GitHub Actions working-directory to change into the target directory before scanning. **Changes:** Action (action.yaml): - Add working-directory to Fossa - Scan step - Add working-directory to Fossa Test step - Uses ${{ env.SCA_FOSSA_PATH || '.' }} to default to current dir - Log which directory is being scanned Schema (fossa-params.json): - Remove SCA_FOSSA_PATH โ†’ --path mapping (invalid flag) - Add note about fossa.path being a special parameter - fossa.path now controls working-directory, not CLI flag Tests (test-parse-fossa-params.sh): - Remove all --path CLI flag assertions - Tests reduced from 22 to 18 (removed 4 --path checks) - All 18 tests passing โœ… Documentation (README.md): - Update fossa.path description to "N/A (working directory)" - Add "Special Parameters" section explaining fossa.path behavior - Clarify it's not a CLI flag but a directory change **Before:** ```bash fossa analyze --path sam-bedrock-agent # โŒ Invalid flag ``` **After:** ```bash cd sam-bedrock-agent # via working-directory fossa analyze # โœ… Scans from correct directory ``` ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/actions/sca/fossa-scan/README.md | 5 ++++- .github/actions/sca/fossa-scan/action.yaml | 6 ++++++ .../actions/sca/fossa-scan/fossa-params.json | 9 +-------- .../sca/fossa-scan/test-parse-fossa-params.sh | 20 +++---------------- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/.github/actions/sca/fossa-scan/README.md b/.github/actions/sca/fossa-scan/README.md index 4a86316..813f654 100644 --- a/.github/actions/sca/fossa-scan/README.md +++ b/.github/actions/sca/fossa-scan/README.md @@ -92,7 +92,7 @@ Generates: `fossa analyze --config sam-mongodb/.fossa.yml --path sam-mongodb` | `fossa.branch` | value | `--branch` | `analyze`, `test` | Branch name for tracking | | `fossa.revision` | value | `--revision` | `analyze`, `test` | Git commit SHA | | `fossa.project` | value | `--project` | `analyze`, `test` | Override project name/ID | -| `fossa.path` | value | `--path` | `analyze` | Base directory to scan | +| `fossa.path` | value | N/A (working directory) | `analyze`, `test` | Base directory to scan from | | `fossa.config` | value | `--config` | `analyze`, `test` | Path to `.fossa.yml` | | `fossa.unpack_archives` | flag | `--unpack-archives` | `analyze` | Unpack and scan archives | | `fossa.without_default_filters` | flag | `--without-default-filters` | `analyze` | Disable default filters | @@ -103,6 +103,9 @@ Generates: `fossa analyze --config sam-mongodb/.fossa.yml --path sam-mongodb` - `test` - Used for the `fossa test` command (checks scan results against policies) - Both commands - Parameter is used by both commands +**Special Parameters:** +- `fossa.path` - Sets the working directory for FOSSA commands. This is not a CLI flag but uses GitHub Actions' `working-directory` to change into the specified directory before running `fossa analyze` and `fossa test`. + See [fossa-params.json](./fossa-params.json) for the complete list with examples. ## Adding New Parameters diff --git a/.github/actions/sca/fossa-scan/action.yaml b/.github/actions/sca/fossa-scan/action.yaml index 6fe86ce..9932264 100644 --- a/.github/actions/sca/fossa-scan/action.yaml +++ b/.github/actions/sca/fossa-scan/action.yaml @@ -28,8 +28,13 @@ runs: - name: Fossa - Scan shell: bash + working-directory: ${{ env.SCA_FOSSA_PATH || '.' }} run: | echo "::group::๐Ÿ” Fossa Scan" + if [ -n "${{ env.SCA_FOSSA_PATH }}" ]; then + echo "Scanning from directory: ${{ env.SCA_FOSSA_PATH }}" + fi + FOSSA_CMD="fossa analyze" echo "Running: $FOSSA_CMD $SCA_FOSSA_ADDITIONAL_ARGS" @@ -39,6 +44,7 @@ runs: - name: FOSSA - Scan Wait For Results continue-on-error: true shell: bash + working-directory: ${{ env.SCA_FOSSA_PATH || '.' }} run: | echo "::group::โณ Fossa Wait For Results" echo "Running: fossa test $SCA_FOSSA_TEST_ARGS" diff --git a/.github/actions/sca/fossa-scan/fossa-params.json b/.github/actions/sca/fossa-scan/fossa-params.json index a7eca04..b61b376 100644 --- a/.github/actions/sca/fossa-scan/fossa-params.json +++ b/.github/actions/sca/fossa-scan/fossa-params.json @@ -35,14 +35,6 @@ "description": "Override project name/ID for FOSSA tracking", "example": "fossa.project=MyOrg_my-project" }, - { - "env": "SCA_FOSSA_PATH", - "flag": "--path", - "type": "value", - "commands": ["analyze"], - "description": "Base directory to scan (useful for monorepos)", - "example": "fossa.path=packages/my-package" - }, { "env": "SCA_FOSSA_CONFIG", "flag": "--config", @@ -81,6 +73,7 @@ "Type 'flag' means boolean - only added if set to 'true'", "Type 'value' means the parameter requires a value and is added if non-empty", "The 'commands' field specifies which FOSSA commands support this parameter: 'analyze' and/or 'test'", + "Special parameter: 'fossa.path' sets the working directory for FOSSA commands (not a CLI flag, uses GitHub Actions working-directory)", "To add a new parameter: add an entry to this file and it will automatically be processed" ] } diff --git a/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh b/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh index 6acdc6b..76c75ef 100755 --- a/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh +++ b/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh @@ -111,7 +111,6 @@ test_multiple_parameters() { assert_contains "$FOSSA_CLI_ARGS" "--debug" "Should include --debug" assert_contains "$FOSSA_CLI_ARGS" "--branch PR" "Should include --branch PR" assert_contains "$FOSSA_CLI_ARGS" "--revision abc123" "Should include --revision" - assert_contains "$FOSSA_CLI_ARGS" "--path sam-mongodb" "Should include --path" assert_contains "$FOSSA_CLI_ARGS" "--config sam-mongodb/.fossa.yml" "Should include --config" unset SCA_FOSSA_ANALYZE_DEBUG SCA_FOSSA_BRANCH SCA_FOSSA_REVISION SCA_FOSSA_PATH SCA_FOSSA_CONFIG @@ -185,7 +184,6 @@ test_command_filtering_analyze() { echo "Test: Command filtering - analyze" export SCA_FOSSA_ANALYZE_DEBUG="true" - export SCA_FOSSA_PATH="sam-mongodb" export SCA_FOSSA_CONFIG="sam-mongodb/.fossa.yml" export FOSSA_PARAMS_CONFIG="$SCRIPT_DIR/fossa-params.json" @@ -193,10 +191,9 @@ test_command_filtering_analyze() { build_fossa_args "analyze" > /dev/null assert_contains "$FOSSA_CLI_ARGS" "--debug" "Analyze should include --debug" - assert_contains "$FOSSA_CLI_ARGS" "--path sam-mongodb" "Analyze should include --path" assert_contains "$FOSSA_CLI_ARGS" "--config sam-mongodb/.fossa.yml" "Analyze should include --config" - unset SCA_FOSSA_ANALYZE_DEBUG SCA_FOSSA_PATH SCA_FOSSA_CONFIG + unset SCA_FOSSA_ANALYZE_DEBUG SCA_FOSSA_CONFIG unset FOSSA_CLI_ARGS } @@ -205,7 +202,6 @@ test_command_filtering_test() { echo "Test: Command filtering - test" export SCA_FOSSA_ANALYZE_DEBUG="true" - export SCA_FOSSA_PATH="sam-mongodb" export SCA_FOSSA_CONFIG="sam-mongodb/.fossa.yml" export SCA_FOSSA_BRANCH="PR" export SCA_FOSSA_REVISION="abc123" @@ -230,15 +226,7 @@ test_command_filtering_test() { ((TEST_PASSED++)) fi - if [[ "$FOSSA_CLI_ARGS" == *"--path"* ]]; then - echo -e "${RED}โœ—${NC} Test should NOT include --path (analyze-only)" - ((TEST_FAILED++)) - else - echo -e "${GREEN}โœ“${NC} Test should NOT include --path (analyze-only)" - ((TEST_PASSED++)) - fi - - unset SCA_FOSSA_ANALYZE_DEBUG SCA_FOSSA_PATH SCA_FOSSA_CONFIG SCA_FOSSA_BRANCH SCA_FOSSA_REVISION SCA_FOSSA_PROJECT + unset SCA_FOSSA_ANALYZE_DEBUG SCA_FOSSA_CONFIG SCA_FOSSA_BRANCH SCA_FOSSA_REVISION SCA_FOSSA_PROJECT unset FOSSA_CLI_ARGS } @@ -246,7 +234,6 @@ test_monorepo_use_case() { echo "" echo "Test: Monorepo use case (real-world scenario)" - export SCA_FOSSA_PATH="sam-mongodb" export SCA_FOSSA_CONFIG="sam-mongodb/.fossa.yml" export SCA_FOSSA_PROJECT="SolaceLabs_sam-mongodb" export SCA_FOSSA_BRANCH="PR" @@ -257,10 +244,9 @@ test_monorepo_use_case() { build_fossa_args > /dev/null assert_contains "$FOSSA_CLI_ARGS" "--project SolaceLabs_sam-mongodb" "Should include project name" - assert_contains "$FOSSA_CLI_ARGS" "--path sam-mongodb" "Should include plugin path" assert_contains "$FOSSA_CLI_ARGS" "--config sam-mongodb/.fossa.yml" "Should include plugin config" - unset SCA_FOSSA_PATH SCA_FOSSA_CONFIG SCA_FOSSA_PROJECT SCA_FOSSA_BRANCH SCA_FOSSA_REVISION + unset SCA_FOSSA_CONFIG SCA_FOSSA_PROJECT SCA_FOSSA_BRANCH SCA_FOSSA_REVISION unset FOSSA_CLI_ARGS } From 08181ce103d6eaf6b2be2f287d9e2e6466f562f4 Mon Sep 17 00:00:00 2001 From: John Corpuz Date: Mon, 22 Dec 2025 14:13:57 -0500 Subject: [PATCH 12/13] fix: Remove --branch from fossa test (analyze-only parameter) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The --branch flag is only supported by 'fossa analyze', not 'fossa test'. Also clarify that fossa.path automatically finds .fossa.yml in that directory. **Changes:** Schema (fossa-params.json): - Change SCA_FOSSA_BRANCH commands from ["analyze", "test"] to ["analyze"] - Add notes explaining fossa.path/fossa.config relationship - Clarify you only need fossa.config if config is elsewhere Tests (test-parse-fossa-params.sh): - Remove assertion that test should include --branch - Add assertion that test should NOT include --branch (analyze-only) - 18 tests, all passing โœ… Documentation (README.md): - Update fossa.branch commands column to "analyze" only - Add note to fossa.config: "(optional if using fossa.path)" - Add detailed explanation in Special Parameters section - Example: fossa.path=sam-bedrock-agent automatically uses sam-bedrock-agent/.fossa.yml **Key Insight:** If you specify `fossa.path=sam-bedrock-agent`, you don't need to also specify `fossa.config=sam-bedrock-agent/.fossa.yml` because FOSSA automatically looks for .fossa.yml in the working directory. **Before:** ```bash fossa test --branch PR # โŒ Invalid - branch not supported by test ``` **After:** ```bash fossa test --revision abc123 --project MyProject # โœ… Valid ``` ๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .github/actions/sca/fossa-scan/README.md | 6 ++++-- .github/actions/sca/fossa-scan/fossa-params.json | 4 +++- .../actions/sca/fossa-scan/test-parse-fossa-params.sh | 9 ++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/actions/sca/fossa-scan/README.md b/.github/actions/sca/fossa-scan/README.md index 813f654..798b374 100644 --- a/.github/actions/sca/fossa-scan/README.md +++ b/.github/actions/sca/fossa-scan/README.md @@ -89,11 +89,11 @@ Generates: `fossa analyze --config sam-mongodb/.fossa.yml --path sam-mongodb` | Parameter | Type | FOSSA Flag | Commands | Description | |-----------|------|------------|----------|-------------| | `fossa.analyze_debug` | flag | `--debug` | `analyze` | Enable debug logging | -| `fossa.branch` | value | `--branch` | `analyze`, `test` | Branch name for tracking | +| `fossa.branch` | value | `--branch` | `analyze` | Branch name for tracking | | `fossa.revision` | value | `--revision` | `analyze`, `test` | Git commit SHA | | `fossa.project` | value | `--project` | `analyze`, `test` | Override project name/ID | | `fossa.path` | value | N/A (working directory) | `analyze`, `test` | Base directory to scan from | -| `fossa.config` | value | `--config` | `analyze`, `test` | Path to `.fossa.yml` | +| `fossa.config` | value | `--config` | `analyze`, `test` | Path to `.fossa.yml` (optional if using fossa.path) | | `fossa.unpack_archives` | flag | `--unpack-archives` | `analyze` | Unpack and scan archives | | `fossa.without_default_filters` | flag | `--without-default-filters` | `analyze` | Disable default filters | | `fossa.force_vendored_dependency_rescans` | flag | `--force-vendored-dependency-rescans` | `analyze` | Force rescan vendored deps | @@ -105,6 +105,8 @@ Generates: `fossa analyze --config sam-mongodb/.fossa.yml --path sam-mongodb` **Special Parameters:** - `fossa.path` - Sets the working directory for FOSSA commands. This is not a CLI flag but uses GitHub Actions' `working-directory` to change into the specified directory before running `fossa analyze` and `fossa test`. + - **Important:** If you specify `fossa.path`, FOSSA will automatically look for `.fossa.yml` in that directory. You only need `fossa.config` if your config file is in a different location or has a non-standard name. + - **Example:** `fossa.path=sam-bedrock-agent` will automatically use `sam-bedrock-agent/.fossa.yml` if it exists. See [fossa-params.json](./fossa-params.json) for the complete list with examples. diff --git a/.github/actions/sca/fossa-scan/fossa-params.json b/.github/actions/sca/fossa-scan/fossa-params.json index b61b376..f042860 100644 --- a/.github/actions/sca/fossa-scan/fossa-params.json +++ b/.github/actions/sca/fossa-scan/fossa-params.json @@ -15,7 +15,7 @@ "env": "SCA_FOSSA_BRANCH", "flag": "--branch", "type": "value", - "commands": ["analyze", "test"], + "commands": ["analyze"], "description": "Branch name for FOSSA project tracking", "example": "fossa.branch=main" }, @@ -74,6 +74,8 @@ "Type 'value' means the parameter requires a value and is added if non-empty", "The 'commands' field specifies which FOSSA commands support this parameter: 'analyze' and/or 'test'", "Special parameter: 'fossa.path' sets the working directory for FOSSA commands (not a CLI flag, uses GitHub Actions working-directory)", + "If you specify 'fossa.path', FOSSA will automatically look for .fossa.yml in that directory - you only need 'fossa.config' if the config is elsewhere", + "Example: fossa.path=sam-bedrock-agent will cd into sam-bedrock-agent and use sam-bedrock-agent/.fossa.yml automatically", "To add a new parameter: add an entry to this file and it will automatically be processed" ] } diff --git a/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh b/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh index 76c75ef..309b9c9 100755 --- a/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh +++ b/.github/actions/sca/fossa-scan/test-parse-fossa-params.sh @@ -212,7 +212,6 @@ test_command_filtering_test() { build_fossa_args "test" > /dev/null # Test command should include these - assert_contains "$FOSSA_CLI_ARGS" "--branch PR" "Test should include --branch" assert_contains "$FOSSA_CLI_ARGS" "--revision abc123" "Test should include --revision" assert_contains "$FOSSA_CLI_ARGS" "--project MyOrg_project" "Test should include --project" assert_contains "$FOSSA_CLI_ARGS" "--config sam-mongodb/.fossa.yml" "Test should include --config" @@ -226,6 +225,14 @@ test_command_filtering_test() { ((TEST_PASSED++)) fi + if [[ "$FOSSA_CLI_ARGS" == *"--branch"* ]]; then + echo -e "${RED}โœ—${NC} Test should NOT include --branch (analyze-only)" + ((TEST_FAILED++)) + else + echo -e "${GREEN}โœ“${NC} Test should NOT include --branch (analyze-only)" + ((TEST_PASSED++)) + fi + unset SCA_FOSSA_ANALYZE_DEBUG SCA_FOSSA_CONFIG SCA_FOSSA_BRANCH SCA_FOSSA_REVISION SCA_FOSSA_PROJECT unset FOSSA_CLI_ARGS } From b6a96158eeef64724a1b9d6d95068713efae55ff Mon Sep 17 00:00:00 2001 From: John Corpuz Date: Mon, 22 Dec 2025 15:05:26 -0500 Subject: [PATCH 13/13] ci: put now with main branch --- .github/actions/sca/sca-scan/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/sca/sca-scan/action.yaml b/.github/actions/sca/sca-scan/action.yaml index 2dce492..491a7e7 100644 --- a/.github/actions/sca/sca-scan/action.yaml +++ b/.github/actions/sca/sca-scan/action.yaml @@ -66,6 +66,6 @@ runs: - name: SCA - Run Fossa scan if: contains(inputs.scanners, 'fossa') - uses: SolaceDev/solace-public-workflows/.github/actions/sca/fossa-scan@specify_fossa_config_path + uses: SolaceDev/solace-public-workflows/.github/actions/sca/fossa-scan@main env: FOSSA_API_KEY: ${{ inputs.fossa_api_key }}