Skip to content

Commit 0a665be

Browse files
committed
Merge branch 'fix/security-and-pipeline-fix' into 'develop'
fix: security findings and pipeline BDA cleanup See merge request genaiic-reusable-assets/engagement-artifacts/genaiic-idp-accelerator!594
2 parents 06434da + c8b6657 commit 0a665be

9 files changed

Lines changed: 2032 additions & 113 deletions

File tree

.github/workflows/developer-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
steps:
3030
- name: Checkout code
31-
uses: actions/checkout@v4
31+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
3232
with:
3333
fetch-depth: 0 # Fetch all history for git diff in typecheck-pr
3434

@@ -89,7 +89,7 @@ jobs:
8989
continue-on-error: false
9090

9191
- name: Upload coverage reports
92-
uses: actions/upload-artifact@v4
92+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
9393
if: always() && steps.run-tests.outcome != 'skipped'
9494
with:
9595
name: test-reports
@@ -99,15 +99,15 @@ jobs:
9999
retention-days: 7
100100

101101
- name: Publish test results
102-
uses: EnricoMi/publish-unit-test-result-action@v2
102+
uses: EnricoMi/publish-unit-test-result-action@c950f6fb443cb5af20a377fd0dfaa78838901040 # v2.23.0
103103
if: always() && hashFiles('lib/idp_common_pkg/test-reports/test-results.xml') != ''
104104
with:
105105
files: lib/idp_common_pkg/test-reports/test-results.xml
106106
check_name: Test Results
107107
comment_mode: off # Disable PR comments to avoid permission issues on fork PRs
108108

109109
- name: Code Coverage Report
110-
uses: irongut/CodeCoverageSummary@v1.3.0
110+
uses: irongut/CodeCoverageSummary@51cc3a756ddcd398d447c044c02cb6aa83fdae95 # v1.3.0
111111
if: always() && hashFiles('lib/idp_common_pkg/test-reports/coverage.xml') != ''
112112
with:
113113
filename: lib/idp_common_pkg/test-reports/coverage.xml

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,7 @@ docs-deploy: docs-build ## Deploy docs to GitHub Pages (from local build)
371371

372372
##@ Security (DSR)
373373
dsr: ## Run full DSR workflow (setup → scan → optional fix)
374-
@if [ ! -f .dsr/dsr ]; then \
375-
echo "DSR not found, running setup..."; \
376-
$(MAKE) dsr-setup; \
377-
fi
374+
@$(MAKE) dsr-setup
378375
@$(MAKE) dsr-scan
379376
@echo ""
380377
@echo "Do you want to run DSR fix? (y/N):"

lib/idp_sdk/idp_sdk/_core/stack.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,14 +1982,34 @@ def is_resource_orphaned(check_stack_name: str) -> bool:
19821982
except Exception as e:
19831983
logger.warning(f"Failed to cleanup IAM custom policies: {e}")
19841984

1985-
# Clean up BDA blueprints associated with this stack
1985+
# Clean up BDA projects and blueprints associated with this stack
19861986
try:
19871987
bda_client = boto3.client(
19881988
"bedrock-data-automation", region_name=self.region
19891989
)
1990+
1991+
# Delete BDA projects first (blueprints are referenced by projects)
1992+
try:
1993+
for p in bda_client.list_data_automation_projects().get(
1994+
"projects", []
1995+
):
1996+
if p.get("projectName", "").startswith(f"{stack_name}-"):
1997+
try:
1998+
bda_client.delete_data_automation_project(
1999+
projectArn=p["projectArn"]
2000+
)
2001+
logger.info(f"Deleted BDA project: {p['projectName']}")
2002+
except Exception as proj_error:
2003+
logger.warning(
2004+
f"Failed to delete BDA project {p['projectName']}: {proj_error}"
2005+
)
2006+
except Exception as e:
2007+
logger.warning(f"Failed to cleanup BDA projects: {e}")
2008+
2009+
# Delete blueprints (versions first, then base)
19902010
paginator = bda_client.get_paginator("list_blueprints")
19912011
deleted_count = 0
1992-
for page in paginator.paginate(blueprintStage="LIVE"):
2012+
for page in paginator.paginate(blueprintStageFilter="LIVE"):
19932013
for blueprint in page.get("blueprints", []):
19942014
bp_name = blueprint.get("blueprintName", "")
19952015
bp_arn = blueprint.get("blueprintArn", "")
@@ -1998,6 +2018,12 @@ def is_resource_orphaned(check_stack_name: str) -> bool:
19982018
continue
19992019
if bp_name.startswith(f"{stack_name}-"):
20002020
try:
2021+
try:
2022+
bda_client.delete_blueprint(
2023+
blueprintArn=bp_arn, blueprintVersion="1"
2024+
)
2025+
except Exception:
2026+
pass
20012027
bda_client.delete_blueprint(blueprintArn=bp_arn)
20022028
deleted_count += 1
20032029
logger.info(f"Deleted BDA blueprint: {bp_name}")

0 commit comments

Comments
 (0)