-
Notifications
You must be signed in to change notification settings - Fork 4
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
US51939: Added malware scan workflow #67
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# (C) Copyright 2023 Hewlett Packard Enterprise Development LP | ||
|
||
name: Malware Scan | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
|
||
jobs: | ||
scan_repository: | ||
name: "Scan Virus on Repository" | ||
runs-on: "ubuntu-latest" | ||
permissions: | ||
id-token: write | ||
contents: read | ||
steps: | ||
- name: "Checkout Repository" | ||
uses: "actions/[email protected]" | ||
with: | ||
fetch-depth: 0 | ||
- name: "Scan Source for Viruses" | ||
id: scan | ||
run: | | ||
SHA_SHORT=$(git rev-parse --short HEAD) | ||
SCAN_OUTPUT=/tmp/clamav-repository-results-${{ github.event.repository.name }}-${SHA_SHORT}-$(date +%s).txt | ||
echo "scan_output=${SCAN_OUTPUT}" >> $GITHUB_OUTPUT | ||
docker run --rm -v ${{ github.workspace }}:/scandir -v /tmp:/tmp -e SCAN_OUTPUT=${SCAN_OUTPUT} clamav/clamav:stable clamscan --infected --recursive --max-files=0 --max-filesize=0 --max-scansize=0 --max-recursion=1000 --max-dir-recursion=1000 /scandir | tee -a $SCAN_OUTPUT | ||
INFECTED_FILES=$(grep ^Infected $SCAN_OUTPUT | awk '{print $NF}') | ||
echo "infected_files=${INFECTED_FILES}" >> $GITHUB_OUTPUT | ||
exit $INFECTED_FILES | ||
- name: "Configure AWS Credentials" | ||
if: always() | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
role-to-assume: arn:aws:iam::522637239241:role/s3-avscan-upload | ||
role-session-name: malware-scan-upload | ||
aws-region: us-west-2 | ||
- name: "Upload Source Scan Results" | ||
if: always() | ||
run: aws s3 cp ${{ steps.scan.outputs.scan_output }} s3://glcs-cloud-security-dev-avscan.hpe-hcss.hpe.com/ | ||
- name: "Tag Scan Upload" | ||
if: always() | ||
run: | | ||
GH_OWNER=${{ github.repository_owner }} | ||
GH_REPO=${{ github.event.repository.name }} | ||
INFECTED_FILES=${{ steps.scan.outputs.infected_files }} | ||
OBJECT_KEY=`basename ${{ steps.scan.outputs.scan_output }}` | ||
aws s3api put-object-tagging \ | ||
--bucket glcs-cloud-security-dev-avscan.hpe-hcss.hpe.com \ | ||
--key $OBJECT_KEY \ | ||
--tagging "{\"TagSet\": [{ \"Key\": \"github_owner\", \"Value\": \"$GH_OWNER\" },{ \"Key\": \"github_repository\", \"Value\": \"$GH_REPO\"},{\"Key\": \"infected_files\", \"Value\": \"$INFECTED_FILES\"}]}" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these HPE AWS roles ? if yes, are we fine to put them in public repos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes its HPE's AWS roles, I asked the same to the security guy who suggested. But not reply back. So, if they come back saying we shouldn't then we can keep in secrets. Or what do you suggest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These repos are open to public and can be accessed by anyone. I do not recommend to expose any users to public repos. We are ideally exposing our AWS Account ID and then the roles. @reubenur-rahman do you have any suggestions here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from Security team : This should be ok because our OIDC role and policy only allows to post the results to the bucket and even though public, a peer reviewed pull request would still be required; being public is all the mor reason to run the scan; I have approved the PR.