Skip to content

Check ufw is active #9149

Check ufw is active

Check ufw is active #9149

Workflow file for this run

name: Compare DS
on:
pull_request_target:
branches: [ master, 'stabilization*' ]
jobs:
build-content:
name: Generate Diff
runs-on: ubuntu-latest
container:
image: fedora:latest
steps:
- name: Install Deps
run: dnf install -y cmake make openscap-utils python3-pyyaml python3-setuptools python3-jinja2 git python3-deepdiff python3-requests jq python3-pip
- name: Install deps python
run: pip install gitpython xmldiff
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
# https://github.com/actions/checkout/issues/766
- name: Set git safe directory
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Find forking point
env:
BASE_BRANCH: ${{ github.base_ref }}
run: echo "FORK_POINT=$(git merge-base origin/$BASE_BRANCH ${{ github.event.pull_request.head.sha }})" >> $GITHUB_OUTPUT
id: fork_point
- name: Checkout fork point
uses: actions/checkout@v4
with:
ref: ${{ steps.fork_point.outputs.FORK_POINT }}
fetch-depth: 0
- name: Checkout (CTF)
uses: actions/checkout@v4
with:
repository: ComplianceAsCode/content-test-filtering
path: ctf
- name: Detect content changes in the PR
run: python3 ./ctf/content_test_filtering.py pr --base ${{ steps.fork_point.outputs.FORK_POINT }} --remote_repo ${{ github.server_url }}/${{ github.repository }} --verbose --rule --output json ${{ github.event.pull_request.number }} > output.json
- name: Test if there are no content changes
run: echo "CTF_OUTPUT_SIZE=$(stat --printf="%s" output.json)" >> $GITHUB_OUTPUT
id: ctf
- name: Print changes to content detected if any
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: cat output.json
- name: Get product attribute
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
id: product
uses: notiz-dev/github-action-json-property@v0.2.0
with:
path: 'output.json'
prop_path: 'product'
- name: Build product ${{ github.base_ref }} (${{ steps.fork_point.outputs.FORK_POINT }})
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: ./build_product ${{steps.product.outputs.prop}} --datastream-only
- name: Copy built datastream stream to be compared
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: cp build/ssg-${{steps.product.outputs.prop}}-ds.xml ssg-${{steps.product.outputs.prop}}-ds.xml
- name: Checkout
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
clean: false
- name: Build product
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: ./build_product ${{steps.product.outputs.prop}} --datastream-only
- name: Compare datastreams
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: utils/compare_ds.py ssg-${{steps.product.outputs.prop}}-ds.xml build/ssg-${{steps.product.outputs.prop}}-ds.xml | tee diff.log
env:
PYTHONPATH: ${{ github.workspace }}
- name: Test if there are datastream changes
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
run: echo "COMPARE_DS_OUTPUT_SIZE=$(stat --printf="%s" diff.log)" >> $GITHUB_OUTPUT
id: compare_ds
- name: Print datastream changes if any
if: ${{ steps.compare_ds.outputs.COMPARE_DS_OUTPUT_SIZE != '0'}}
run: cat diff.log
- name: Get diff.log
if: ${{ steps.compare_ds.outputs.COMPARE_DS_OUTPUT_SIZE != '0'}}
id: diff
run: |
body=$(cat diff.log)
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "log<<$EOF" >> "$GITHUB_OUTPUT"
echo "${body:0:65000}" >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: This datastream diff is auto generated by the check
- name: Create or update comment
if: ${{ steps.compare_ds.outputs.COMPARE_DS_OUTPUT_SIZE != '0' && steps.compare_ds.outputs.COMPARE_DS_OUTPUT_SIZE <= 65000 }}
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
This datastream diff is auto generated by the check `Compare DS/Generate Diff`
<details>
<summary>Click here to see the full diff</summary>
```diff
${{ steps.diff.outputs.log }}
```
</details>
edit-mode: replace
- name: Create or update a trimmed comment
if: ${{ steps.compare_ds.outputs.COMPARE_DS_OUTPUT_SIZE > 65000 }}
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
This datastream diff is auto generated by the check `Compare DS/Generate Diff`.
Due to the excessive size of the diff, it has been trimmed to fit the 65535-character limit.
<details>
<summary>Click here to see the trimmed diff</summary>
```diff
${{ steps.diff.outputs.log }}
... The diff is trimmed here ...
```
</details>
edit-mode: replace
- name: Delete existing comment in case new commits trigger no changes in Compare DS tool
if: ${{ (steps.compare_ds.outputs.COMPARE_DS_OUTPUT_SIZE == '0' || steps.ctf.outputs.CTF_OUTPUT_SIZE == '0') && steps.fc.outputs.comment-id != 0 }}
uses: jungwinter/comment@v1
with:
type: delete
comment_id: ${{ steps.fc.outputs.comment-id }}
token: ${{ secrets.GITHUB_TOKEN }}