Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

also copy csp_report block to Dockerfile #1001

Merged
merged 2 commits into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/copy_csp_blocks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ jobs:
run: |
echo "Chef Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" >> $GITHUB_STEP_SUMMARY

paste_enforce_csp_into_dockerfile_repo:
paste_csp_into_dockerfile_repo:
needs: copy_csp
runs-on: ubuntu-latest
env:
csp_report_on: ${{ needs.copy_csp.outputs.csp_report_on }}
csp_enforce_on: ${{ needs.copy_csp.outputs.csp_enforce_on }}
ap_file: "application.properties"
steps:
Expand All @@ -150,6 +151,7 @@ jobs:
printf "\n\n>>>> $ap_file before I change it: <<<<\n\n"
cat $ap_file

printf "\n\n>>>> caught csp_report_on env var: <<<<\n$csp_report_on n\n"
printf "\n\n>>>> caught csp_enforce_on env var:<<<<\n$csp_enforce_on\n\n"

printf "\n\n>>>> replacing csp block in $ap_file <<<<\n\n"
Expand All @@ -160,6 +162,11 @@ jobs:
os.rename(fname, fname + '.orig')
with open(fname + '.orig', 'r') as fin, open(fname, 'w') as fout:
data = fin.read()
data = re.sub(r'(## START OF CSP REPORT BLOCK \\(DO NOT CHANGE THIS TEXT\\)).*?(## END OF CSP REPORT BLOCK \\(DO NOT CHANGE THIS TEXT\\))',
r'\1\n' +
os.environ.get('csp_report_on') +
r'\n\2', data, flags=re.DOTALL)

data = re.sub(r'(## START OF CSP ENFORCE BLOCK \\(DO NOT CHANGE THIS TEXT\\)).*?(## END OF CSP ENFORCE BLOCK \\(DO NOT CHANGE THIS TEXT\\))',
r'\1\n' +
os.environ.get('csp_enforce_on') +
Expand Down