Skip to content

Commit 30d576a

Browse files
committed
Make scan release list configurable through repository variables
1 parent 75aa046 commit 30d576a

File tree

2 files changed

+49
-28
lines changed

2 files changed

+49
-28
lines changed

.github/workflows/security-scan.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ permissions:
5454
env:
5555
PYTHON_VERSION: '3.11'
5656
OUTPUT_DIR: 'data'
57+
# GitHub variables for configurable scan targets
58+
DEFAULT_RELEASES: ${{ vars.DEFAULT_RELEASES || 'v5.4.2,v5.4.1,v5.3.3,v5.3.2,v5.2.5,v5.2.4,v5.1.6,v5.1.5,v5.0.9,v5.0.8' }}
59+
ESP_IDF_RELEASE_BRANCHES: ${{ vars.ESP_IDF_RELEASE_BRANCHES || 'master,release/v5.5,release/v5.4,release/v5.3,release/v5.2,release/v5.1,release/v5.0' }}
60+
ESP_IDF_DEV_BRANCHES: ${{ vars.ESP_IDF_DEV_BRANCHES || 'master,develop' }}
5761

5862
jobs:
5963
# Single unified scanning job - maximum efficiency
@@ -184,8 +188,8 @@ jobs:
184188
185189
# Add development branch scanning if requested
186190
if [[ "${{ steps.config.outputs.include_branches }}" == "true" ]]; then
187-
SCAN_CMD="$SCAN_CMD --include-branches master,develop"
188-
echo "🌿 Including development branches: master, develop"
191+
SCAN_CMD="$SCAN_CMD --include-branches ${{ env.ESP_IDF_DEV_BRANCHES }}"
192+
echo "🌿 Including development branches: ${{ env.ESP_IDF_DEV_BRANCHES }}"
189193
fi
190194
191195
echo ""

scan_releases.py

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,39 @@
5353
# Note: v5.0.3, v5.0.2, v5.0.1, v5.0 excluded due to limited SBOM support
5454
}
5555

56-
# Default releases to scan (most recent stable versions)
57-
DEFAULT_RELEASES = [
58-
'v5.4.2', 'v5.4.1',
59-
'v5.3.3', 'v5.3.2',
60-
'v5.2.5', 'v5.2.4',
61-
'v5.1.6', 'v5.1.5',
62-
'v5.0.9', 'v5.0.8'
63-
]
56+
# Default releases to scan (configurable via environment variables)
57+
def get_default_releases():
58+
"""Get default releases from environment variable or use hardcoded fallback"""
59+
env_releases = os.getenv('DEFAULT_RELEASES')
60+
if env_releases:
61+
return [r.strip() for r in env_releases.split(',')]
62+
return [
63+
'v5.4.2', 'v5.4.1',
64+
'v5.3.3', 'v5.3.2',
65+
'v5.2.5', 'v5.2.4',
66+
'v5.1.6', 'v5.1.5',
67+
'v5.0.9', 'v5.0.8'
68+
]
6469

65-
# ESP-IDF release branches to scan
66-
ESP_IDF_RELEASE_BRANCHES = [
67-
'master',
68-
'release/v5.5',
69-
'release/v5.4',
70-
'release/v5.3',
71-
'release/v5.2',
72-
'release/v5.1',
73-
'release/v5.0'
74-
]
70+
# ESP-IDF release branches to scan (configurable via environment variables)
71+
def get_esp_idf_release_branches():
72+
"""Get ESP-IDF release branches from environment variable or use hardcoded fallback"""
73+
env_branches = os.getenv('ESP_IDF_RELEASE_BRANCHES')
74+
if env_branches:
75+
return [b.strip() for b in env_branches.split(',')]
76+
return [
77+
'master',
78+
'release/v5.5',
79+
'release/v5.4',
80+
'release/v5.3',
81+
'release/v5.2',
82+
'release/v5.1',
83+
'release/v5.0'
84+
]
85+
86+
# Legacy constants for backwards compatibility
87+
DEFAULT_RELEASES = get_default_releases()
88+
ESP_IDF_RELEASE_BRANCHES = get_esp_idf_release_branches()
7589

7690
class ESPIDFSecurityScanner:
7791
def __init__(self, output_dir, use_docker=True):
@@ -652,7 +666,7 @@ def scan_releases(self, releases, include_branches=None, include_release_branche
652666

653667
# Add release branches
654668
if include_release_branches:
655-
git_targets.extend(ESP_IDF_RELEASE_BRANCHES)
669+
git_targets.extend(get_esp_idf_release_branches())
656670

657671
# Add custom branches
658672
if include_branches:
@@ -684,8 +698,9 @@ def scan_releases(self, releases, include_branches=None, include_release_branche
684698

685699
# Scan ESP-IDF release branches if requested (and not in batch mode)
686700
if include_release_branches:
687-
logger.info(f"Scanning ESP-IDF release branches: {ESP_IDF_RELEASE_BRANCHES}")
688-
for branch in ESP_IDF_RELEASE_BRANCHES:
701+
release_branches = get_esp_idf_release_branches()
702+
logger.info(f"Scanning ESP-IDF release branches: {release_branches}")
703+
for branch in release_branches:
689704
version_id, scan_result = self.scan_latest_branch(branch)
690705
if scan_result:
691706
tool_version = self.get_tool_version()
@@ -840,10 +855,11 @@ def main():
840855
return
841856

842857
if args.list_release_branches:
858+
release_branches = get_esp_idf_release_branches()
843859
print("Available ESP-IDF release branches:")
844-
for branch in ESP_IDF_RELEASE_BRANCHES:
860+
for branch in release_branches:
845861
print(f" {branch}")
846-
print(f"\nTotal: {len(ESP_IDF_RELEASE_BRANCHES)} release branches")
862+
print(f"\nTotal: {len(release_branches)} release branches")
847863
print("\nTo scan these branches, use: --include-release-branches")
848864
return
849865

@@ -879,7 +895,7 @@ def main():
879895
elif args.versions:
880896
versions = [v.strip() for v in args.versions.split(',')]
881897
else:
882-
versions = DEFAULT_RELEASES
898+
versions = get_default_releases()
883899

884900
branches = None
885901
if args.include_branches:
@@ -893,15 +909,16 @@ def main():
893909
logger.info(f"Git-only mode: {args.git_only}")
894910
logger.info(f"Versions to scan: {len(versions)}")
895911
if args.include_release_branches:
896-
logger.info(f"Release branches to scan: {len(ESP_IDF_RELEASE_BRANCHES)}")
912+
release_branches = get_esp_idf_release_branches()
913+
logger.info(f"Release branches to scan: {len(release_branches)}")
897914
if branches:
898915
logger.info(f"Custom branches to scan: {branches}")
899916

900917
# Use unified mode if requested
901918
if args.unified_mode:
902919
all_targets = versions[:]
903920
if args.include_release_branches:
904-
all_targets.extend(ESP_IDF_RELEASE_BRANCHES)
921+
all_targets.extend(get_esp_idf_release_branches())
905922
if branches:
906923
all_targets.extend(branches)
907924

0 commit comments

Comments
 (0)