-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FE][CPF-39]: Scan frontend with Trivy (#47)
* feat: api refactor, docker image push action * feat: scan and upload to security * chore: change owner name * feat: adjust envs
- Loading branch information
Showing
10 changed files
with
134 additions
and
66 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
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,55 @@ | ||
name: Scan Frontend with Trivy | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
- ready_for_review | ||
branches: | ||
- main | ||
- develop | ||
|
||
env: | ||
IMAGE_NAME: frontend | ||
VERSION: v1 | ||
|
||
jobs: | ||
build_docker_image: | ||
name: Build docker image | ||
timeout-minutes: 15 | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: frontend | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build docker image | ||
run: docker build . --file Dockerfile --tag $IMAGE_NAME | ||
|
||
- name: Log in to gHRC | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Push image | ||
run: | | ||
docker tag $IMAGE_NAME ghcr.io/tivix/cpf/$IMAGE_NAME:$VERSION | ||
docker push ghcr.io/tivix/cpf/$IMAGE_NAME:$VERSION | ||
- name: Run Trivy vulnerability scanner | ||
uses: aquasecurity/[email protected] | ||
with: | ||
image-ref: "ghcr.io/tivix/cpf/${{ env.IMAGE_NAME }}:${{ env.VERSION }}" | ||
scanners: "vuln,secret,config" | ||
format: "sarif" | ||
output: "trivy-fe-results.sarif" | ||
severity: "CRITICAL,HIGH" | ||
|
||
- name: Upload scan result to Github Security | ||
uses: github/codeql-action/upload-sarif@v3 | ||
with: | ||
sarif_file: trivy-fe-results.sarif | ||
category: "image" |
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,16 @@ | ||
import { mapKeysToCamelCase } from '@app/utils'; | ||
import { API_URLS } from '.'; | ||
import { Bucket } from '@app/types/common'; | ||
|
||
async function getBucketDetails(slug: string) { | ||
const response = await fetch(`${API_URLS.library.buckets}/${slug}`); | ||
|
||
if (!response.ok) { | ||
throw new Error('Failed to fetch bucket details'); | ||
} | ||
const data = await response.json(); | ||
|
||
return mapKeysToCamelCase<Bucket>(data); | ||
} | ||
|
||
export { getBucketDetails }; |
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,45 @@ | ||
import { mapKeysToCamelCase } from '@app/utils'; | ||
import { API_URLS } from '.'; | ||
import { LadderCardInterface } from '@app/components/common/LadderCard'; | ||
import { LadderBand } from '@app/types/common'; | ||
|
||
async function getLadders() { | ||
const response = await fetch(API_URLS.library.ladders); | ||
|
||
if (!response.ok) { | ||
throw new Error('Failed to fetch ladders'); | ||
} | ||
const data = await response.json(); | ||
|
||
return mapKeysToCamelCase<LadderCardInterface[]>(data); | ||
} | ||
|
||
async function getLadderDetails(slug: string) { | ||
const response = await fetch(`${API_URLS.library.ladders}/${slug}`); | ||
|
||
if (!response.ok) { | ||
throw new Error('Failed to fetch ladder details'); | ||
} | ||
const data = await response.json(); | ||
|
||
return mapKeysToCamelCase<{ | ||
ladderName: string; | ||
bands: Record<string, LadderBand>; | ||
}>(data); | ||
} | ||
|
||
async function getLadderName(slug: string) { | ||
const response = await fetch(`${API_URLS.library.ladders}/${slug}`); | ||
|
||
if (!response.ok) { | ||
throw new Error('Failed to fetch ladder details'); | ||
} | ||
const data = await response.json(); | ||
|
||
return mapKeysToCamelCase<{ | ||
ladderName: string; | ||
bands: Record<string, LadderBand>; | ||
}>(data).ladderName; | ||
} | ||
|
||
export { getLadders, getLadderDetails, getLadderName }; |
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
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export const CloseIcon: React.FC<React.SVGProps<SVGSVGElement>> = (props) => ( | ||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}> | ||
<path d="M0.75 0.75L15.25 15.25M15.25 0.75L0.75 15.25" stroke="#555C6B" stroke-width="1.5" stroke-linecap="round" /> | ||
<path d="M0.75 0.75L15.25 15.25M15.25 0.75L0.75 15.25" stroke="#555C6B" strokeWidth="1.5" strokeLinecap="round" /> | ||
</svg> | ||
); |