-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #comment adding additional docs
- Loading branch information
Showing
7 changed files
with
191 additions
and
123 deletions.
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
150 changes: 57 additions & 93 deletions
150
docs/content/tutorials/CI/ASH Execution Environment Viability.drawio
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions
45
docs/content/tutorials/CI/GitHubActions/.github/workflows/run-ash-scan.yml
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,45 @@ | ||
# | ||
# This example clones the ASH repo and the repo to be scanned, then runs `ash` | ||
# against the repo. | ||
# | ||
# This will build the ASH container image, run the scan using the built image, | ||
# and publish the scan results as a build artifact. | ||
# | ||
name: ASH SAST Scan | ||
|
||
on: | ||
push: | ||
branches: [ '**' ] | ||
|
||
env: | ||
ASH_OUTPUT_PATH: ash_output | ||
|
||
jobs: | ||
containerjob: | ||
name: Run ASH Scan | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout ASH | ||
uses: actions/checkout@v4 | ||
with: | ||
path: ./automated-security-helper | ||
repository: awslabs/automated-security-helper | ||
ref: v1.3.3 | ||
- name: Checkout app repo | ||
uses: actions/checkout@v4 | ||
with: | ||
path: ./repo | ||
- name: Run ASH scan against repo | ||
run: | | ||
export PATH="$(pwd)/automated-security-helper:$PATH" | ||
ash \ | ||
--source-dir "$(pwd)/repo" \ | ||
--output-dir "${{ env.ASH_OUTPUT_PATH }}" | ||
- name: Publish ${{ env.ASH_OUTPUT_PATH }} | ||
uses: actions/upload-artifact@v3 | ||
if: success() || failure() | ||
with: | ||
name: ${{ env.ASH_OUTPUT_PATH }} | ||
path: ${{ env.ASH_OUTPUT_PATH }} |
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,33 @@ | ||
# | ||
# This example clones the ASH repo and the repo to be scanned, then runs `ash` | ||
# against the repo. | ||
# | ||
# This will build the ASH container image, run the scan using the built image, | ||
# and publish the scan results as a build artifact. | ||
# | ||
variables: | ||
ASH_VERSION: | ||
description: The version tag of the awslabs/automated-security-helper repo to clone | ||
value: v1.3.3 | ||
|
||
Run ASH Scan: | ||
stage: .pre | ||
when: always | ||
script: | ||
# Clone the ASH repository from GitHub at the desired version | ||
- |- | ||
git clone https://github.com/awslabs/automated-security-helper.git \ | ||
../automated-security-helper \ | ||
--branch "$ASH_VERSION" | ||
# Add the ASH repo path to $PATH so `ash` is available in PATH | ||
- export PATH="$(pwd)/../automated-security-helper:$PATH" | ||
# Run `ash`. | ||
# This will build the ASH container first, then run the scan once built. | ||
- |- | ||
ash \ | ||
--source-dir "$(pwd)" \ | ||
--output-dir "$(pwd)/ash_output" | ||
artifacts: | ||
paths: | ||
- ash_output | ||
when: always |
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
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,37 @@ | ||
## Continuous Integration (CI) Execution | ||
|
||
ASH supports running in CI environments as an executable container (e.g. via `docker run`) as well as via Container Job mechanisms, depending on CI platform support. | ||
|
||
Within the CI folder, there are multiple examples of running ASH scans in various CI platforms. All examples include the following: | ||
|
||
* ASH repository is cloned from GitHub alongside the repository to be scanned. | ||
* ASH repository directory is added to `$PATH` so that `ash` is available to call directly. | ||
* `ash` is called to invoke the scan, which performs the following steps: | ||
1. Creates the `ash_output` directory if it does not already exist | ||
2. Builds the ASH container image | ||
3. Runs the ASH scan using the built container image | ||
4. Generates the results in the `ash_output` directory | ||
* Once `ash` is complete, uploads `ash_output` directory as a build artifact. | ||
|
||
These examples are meant to show simple implementations that will enable quick integration of ASH | ||
into an application or infrastructure CI pipeline. | ||
|
||
--- | ||
|
||
Current examples provided by subfolder name: | ||
|
||
<!-- * Azure Pipelines (`azure-pipelines.yml`) | ||
* Example file shows how to run an ASH scan using Azure Pipelines [ContainerJobs](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/container-phases?view=azure-devops). --> | ||
* GitHub Actions (`.github/workflows/run-ash.yml`) | ||
* Job `containerjob`: Example shows how to run ASH with the ASH image itself used for the job execution. This aligns with the `ContainerJob` approach from Azure Pipelines and presents the `ash` script as a callable in PATH. | ||
* Job `dockerrun`: Example shows how to run an ASH scan using generic `docker run` invocation (seen below) | ||
* GitLab CI (`.gitlab-ci.yml`) | ||
* Example file shows how to use the ASH image as the runner image in a GitLab CI job | ||
<!-- * Jenkins (`Jenkinsfile`) | ||
* Example file shows a scripted pipeline that runs an ASH scan using `docker run` with ASH as a containerized executable. --> | ||
|
||
### ASH Execution Environment Viability | ||
|
||
If you are unsure whether ASH will run in your CI environment or not, the primary requirement is the ability to run Linux containers. This is typically true for most CI platforms, but self-hosted CI agents and enterprise security rules may restrict that ability. If you are unsure whether the CI platform you are using will support it, you can walk through the following flowchart for guidance: | ||
|
||
![ASH Execution Environment Viability diagram PNG](CI/ASH%20Execution%20Environment%20Viability.png) |