Skip to content
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.

Merge upstream #67

Open
wants to merge 72 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
63ce0da
Bump y18n from 4.0.0 to 4.0.1
dependabot[bot] Mar 31, 2021
42bdc19
fix version matching in tests
m-vdb Apr 16, 2021
33e6998
issue body should contain image name
m-vdb Apr 16, 2021
d9d33fb
bump build
m-vdb Apr 16, 2021
995f2ce
Merge pull request #3 from m-vdb/master
wochinge Apr 20, 2021
f7b734d
Bump lodash from 4.17.19 to 4.17.21
dependabot[bot] May 11, 2021
83a14e2
Bump hosted-git-info from 2.8.5 to 2.8.9
dependabot[bot] May 11, 2021
9464890
Merge pull request #79 from lazy-actions/dependabot/npm_and_yarn/host…
homoluctus Jun 3, 2021
1a7369f
Merge pull request #78 from lazy-actions/dependabot/npm_and_yarn/loda…
homoluctus Jun 3, 2021
8783ccc
Merge pull request #77 from lazy-actions/dependabot/npm_and_yarn/y18n…
homoluctus Jun 3, 2021
2092e59
Bump axios from 0.19.2 to 0.21.1
dependabot[bot] Jun 3, 2021
9ca5ec4
Bump @actions/core from 1.2.2 to 1.2.6
dependabot[bot] Jun 3, 2021
cf0ad4b
Merge pull request #73 from lazy-actions/dependabot/npm_and_yarn/axio…
homoluctus Jun 3, 2021
0bfcfee
Merge pull request #69 from lazy-actions/dependabot/npm_and_yarn/acti…
homoluctus Jun 3, 2021
f55d002
Merge pull request #62 from wochinge/master
homoluctus Jun 3, 2021
5617415
ci: Organiza GitHub Actions workflows
homoluctus Jun 3, 2021
f9e7bed
ci: Add auto build workflow
homoluctus Jun 3, 2021
3278c29
ci: Call integration test after Build workflow completed
homoluctus Jun 3, 2021
d537ee8
Merge pull request #80 from lazy-actions/feat/organize-workflows
homoluctus Jun 3, 2021
84a54d9
chore(readme): Change gitrivy branch name in example
homoluctus Jun 3, 2021
2958143
Merge pull request #81 from lazy-actions/feat/change-default-branch
homoluctus Jun 3, 2021
85fdf6d
ci: Add a workflow to tweet new version
homoluctus Jun 3, 2021
58c3e9b
Merge pull request #82 from lazy-actions/feat/add-tweet-workflow
homoluctus Jun 3, 2021
08dfb6d
chore: Move image to assets dir
homoluctus Jun 3, 2021
8729ba5
chore(readme): Add badges
homoluctus Jun 3, 2021
30db59c
chore(deps): Update dependencies
homoluctus Jun 3, 2021
1c5422b
Merge pull request #83 from lazy-actions/chore/update-deps
homoluctus Jun 3, 2021
aa7b49c
ci: Fix branch name in build workflow
homoluctus Jun 3, 2021
04f21ba
Merge pull request #84 from lazy-actions/fix/branch
homoluctus Jun 3, 2021
99e3e7b
ci: Use knqyf263/vuln-image includes vulnerabilities as test docker i…
homoluctus Jun 3, 2021
67aaf17
chore(deps): Upgrade @actions/core and @actions/github
homoluctus Jun 3, 2021
cf18e5d
chore(deps): Install @octokit/rest to request GitHub API
homoluctus Jun 3, 2021
dfdbd74
refactor: Separate trivy and downloader
homoluctus Jun 3, 2021
f73382e
chore(tsconfig): Add __tests__/helper.ts
homoluctus Jun 3, 2021
3d8c771
test: Fix expected value in release asset url
homoluctus Jun 3, 2021
a95b6de
Merge pull request #85 from lazy-actions/refactor
homoluctus Jun 3, 2021
f99f703
fix(github): Consider that GitHub Issue body is undefined
homoluctus Jun 3, 2021
052dd14
Merge pull request #86 from lazy-actions/fix/type-error
homoluctus Jun 3, 2021
d2beb36
ci: Create pull request after transpile
homoluctus Jun 3, 2021
45ac207
Merge pull request #87 from lazy-actions/fix/ci
homoluctus Jun 3, 2021
3beb88d
chore(prettier): trailingComma is none
homoluctus Jun 3, 2021
5e2b734
chore: Add trivy template
homoluctus Jun 3, 2021
325d3db
feat: Support trivy template option
homoluctus Jun 3, 2021
0d9e3c8
test: Modify to support trivy template option
homoluctus Jun 3, 2021
63e138a
chore: Modify action metadata to support template option
homoluctus Jun 3, 2021
a753d63
Merge pull request #88 from lazy-actions/feat/use-template-option
homoluctus Jun 3, 2021
e3231be
build: Transpile
homoluctus Jun 3, 2021
eaefbcd
ci: Unify YAML extension to yaml
homoluctus Jun 3, 2021
3d3ed11
Merge pull request #90 from lazy-actions/fix/it-test-trigger
homoluctus Jun 3, 2021
245f58d
Merge pull request #89 from lazy-actions/create-pull-request/patch
homoluctus Jun 3, 2021
dd5695a
refactor: Separate the process of input parameters
homoluctus Jun 3, 2021
cd7e033
refactor: Use Validator interface for validator classes
homoluctus Jun 3, 2021
649dc51
feat: Add validate function for template parameter
homoluctus Jun 3, 2021
a09f0f7
test: Add a test for inputs.ts
homoluctus Jun 3, 2021
133cc55
refactor: Separate inputs and validator in two files
homoluctus Jun 3, 2021
f95014a
test: Add a test for validator
homoluctus Jun 3, 2021
5862e97
Merge pull request #91 from lazy-actions/refactor/inputs
homoluctus Jun 3, 2021
276493c
build: Transpile
homoluctus Jun 3, 2021
038d7e0
Merge pull request #92 from lazy-actions/create-pull-request/patch
homoluctus Jun 3, 2021
3279ae9
ci: Add workflow_dispatch to integration test as trigger
homoluctus Jun 3, 2021
47bbe3c
Merge pull request #93 from lazy-actions/feat/introduce-workflow-disp…
homoluctus Jun 3, 2021
381b4a7
chore(template): Remove unneed codes
homoluctus Jun 3, 2021
b9f66c1
feat: Check template parameter prefix is @
homoluctus Jun 3, 2021
e69b0bf
Merge pull request #95 from lazy-actions/fix/template
homoluctus Jun 3, 2021
cf1cc30
chore: Move default.tpl from src/template/ to src/
homoluctus Jun 3, 2021
9de95ee
Merge pull request #97 from lazy-actions/chore/move-default-template
homoluctus Jun 3, 2021
e7d128a
build: Transpile
homoluctus Jun 3, 2021
0601767
Merge pull request #98 from lazy-actions/create-pull-request/patch
homoluctus Jun 3, 2021
ef8596e
chore(readme): Update image and description
homoluctus Jun 3, 2021
6edf95f
Merge pull request #100 from lazy-actions/feat/update-readme
homoluctus Jun 3, 2021
843a7d6
chore(readme): Update action version in example
homoluctus Jun 3, 2021
010deae
Merge pull request #101 from lazy-actions/feat/update-readme
homoluctus Jun 3, 2021
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
39 changes: 39 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build

on:
push:
branches:
- main
paths:
- "**.ts"
- "package.json"
- "yarn.lock"
- "tsconfig.json"

jobs:
build:
name: Transpile Typescript
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: '14'

- name: Setup workspace
run: yarn install --frozen-lockfile

- name: Transpile
run: yarn run build

- name: Commit
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit -m "build: Transpile" || echo "No changes to commit"

- uses: peter-evans/create-pull-request@v3
with:
title: 'Transpile'
28 changes: 28 additions & 0 deletions .github/workflows/integration-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Integration Test

on:
pull_request:
paths:
- 'dist/**'
workflow_dispatch:

env:
IMAGE_NAME: knqyf263/vuln-image

jobs:
test:
name: Integration Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Pull docker image
run: docker pull ${{ env.IMAGE_NAME }}

- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
image: ${{ env.IMAGE_NAME }}
issue_label: trivy,vulnerability,test
issue_title: Security Alert Test
issue_assignee: homoluctus
36 changes: 0 additions & 36 deletions .github/workflows/release.yml

This file was deleted.

102 changes: 0 additions & 102 deletions .github/workflows/test.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .github/workflows/tweet-action/template.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Release lazy-actions/gitrivy version <%- version %> 🎉🎉🎉
<%- url %>

#GitHub #GitHubActions #Trivy
26 changes: 26 additions & 0 deletions .github/workflows/twitter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Twitter

on:
release:
types:
- "published"

jobs:
tweet:
name: Tweet New Version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: lazy-actions/tweet-action@main
with:
data: |
{
"version": "${{ github.event.release.tag_name }}",
"url": "${{ github.event.release.html_url }}"
}
template_filename: .github/workflows/tweet-action/template.ejs
oauth_consumer_key: ${{ secrets.TWITTER_CONSUMER_KEY }}
oauth_consumer_secret: ${{ secrets.TWITTER_CONSUMER_SECRET }}
oauth_token: ${{ secrets.TWITTER_TOKEN }}
oauth_token_secret: ${{ secrets.TWITTER_TOKEN_SECRET }}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ on:
pull_request:
paths:
- 'src/**'
- 'dist/**'
- tsconfig.json
- package.json
- yarn.lock

jobs:
jest:
name: Test with jest
runs-on: ubuntu-18.04
test:
name: Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: '12.x'

Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
semi: true
singleQuote: true
trailingComma: es5
trailingComma: none
parser": typescript
bracketSpacing: true
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,47 @@
# Gitrivy
# Gitrivy (GitHub Issue + Trivy Action)

![GitHub Workflow Status](https://img.shields.io/github/workflow/status/lazy-actions/gitrivy/Build)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/lazy-actions/gitrivy/Integration%20Test?label=Integration%20Test)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/lazy-actions/gitrivy/Unit%20Test?label=Unit%20Test)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/homoluctus/gitrivy?color=brightgreen&include_prereleases)
![GitHub](https://img.shields.io/github/license/homoluctus/gitrivy?color=brightgreen)
![LICENSE](https://img.shields.io/github/license/homoluctus/gitrivy?color=brightgreen)

This is a GitHub Actions to scan vulnerability using [Trivy](https://github.com/aquasecurity/trivy).<br>
If vulnerabilities are found by Trivy, it creates the following GitHub Issue.

![image](https://github.com/homoluctus/gitrivy/blob/master/issue.png)
![image](./assets/img/issue.png)

## Usage
## Feature

### Inputs
- Scan vulnerability used by Trivy
- Create or Update GitHub Issue if vulnerabilities found
- Customize Issue title, label and assignee
- Issue body is generated by template parameter

## Inputs

|Parameter|Required|Default Value|Description|
|:--:|:--:|:--:|:--|
|trivy_version|False|latest|Trivy version|
|token|True|N/A|GitHub Access Token.<br>${{ secrets.GITHUB_TOKEN }} is recommended.|
|image|True|N/A|The target image name to scan the vulnerability<br>Specify this parameter or `IMAGE_NAME` environment variable|
|trivy_version|False|latest|Trivy version|
|severity|False|HIGH,CRITICAL|Severities of vulnerabilities (separated by commma)|
|vuln_type|False|os,library|Scan target are os and / or library (separated by commma)|
|ignore_unfixed|False|false|Ignore unfixed vulnerabilities<br>Please specify `true` or `false`|
|issue|False|true|Decide whether creating issue when vulnerabilities are found by trivy.<br>Please specify `true` or `false`|
|token|True if issue parameter is true else False|N/A|GitHub Access Token.<br>${{ secrets.GITHUB_TOKEN }} is recommended.|
|template|False|N/A|Path to template file<br>This parameter equals trivy --template option<br>By default, it uses src/default.tpl which is based on [contrib/html.tpl](https://github.com/aquasecurity/trivy/blob/main/contrib/html.tpl)<br>reference: [Report Formats - Trivy](https://aquasecurity.github.io/trivy/v0.18.3/examples/report/#template)|
|issue_title|False|Security Alert|Issue title|
|issue_label|False|trivy,vulnerability|Issue label (separated by commma)|
|issue_assignee|False|N/A|Issue assignee (separated by commma)|
|fail_on_vulnerabilities|False|false|Whether the action should fail if any vulnerabilities were found.|

### Outputs
## Outputs

|Parameter|Description|
|:--:|:--|
|html_url|The URL to view the issue|
|issue_number|The created issue number|

## Example Workflow
## Example

Detect your docker image vulnerability everyday at 9:00 (UTC).

Expand All @@ -46,12 +55,12 @@ on:
jobs:
scan:
name: Daily Vulnerability Scan
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Pull docker image
run: docker pull sample

- uses: homoluctus/gitrivy@v1.0.0
- uses: lazy-actions/gitrivy@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
image: sample
Expand Down
Loading