Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneRifle committed Mar 4, 2024
0 parents commit 9df9835
Show file tree
Hide file tree
Showing 29 changed files with 27,324 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NODE_ENV=development

VIRUS_SCANNER_QUARANTINE_S3_BUCKET='local-virus-scanner-quarantine-bucket'
VIRUS_SCANNER_CLEAN_S3_BUCKET='local-virus-scanner-clean-bucket'
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NODE_ENV=development

VIRUS_SCANNER_QUARANTINE_S3_BUCKET='local-virus-scanner-quarantine-bucket'
VIRUS_SCANNER_CLEAN_S3_BUCKET='local-virus-scanner-clean-bucket'
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["opengovsg"],
"ignorePatterns": ["coverage"]
}
38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: build
on:
push:
pull_request:
types: [opened, reopened]
jobs:
test:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- run: npm ci
- run: npm test
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- run: npm ci
- run: npm run build
- run: npm_config_mode=yes npx lockfile-lint --type npm --path package.json --validate-https --allowed-hosts npm
- run: npm run lint
64 changes: 64 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: "CodeQL"

on:
push:
pull_request:
types: [opened, reopened]
schedule:
- cron: '0 21 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['javascript']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
61 changes: 61 additions & 0 deletions .github/workflows/deploy-aws.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Deploy Scanner to AWS

on:
workflow_call:
inputs:
environment:
description: 'Deployment environment'
required: true
type: string
provisionedConcurrency:
description: 'Provisioned concurrency'
required: true
type: number
checkoutBranch:
description: 'Branch to checkout code from'
required: true
type: string

permissions:
id-token: write
contents: read

jobs:
virus-scanner:
name: virus scanner serverless
runs-on: ubuntu-latest

steps:
- name: Checkout source code from specified checkout branch
uses: actions/checkout@v3
with:
ref: ${{ inputs.checkoutBranch }}

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.OS }}-node-scanner-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-scanner-
${{ runner.OS }}-node-
- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
role-to-assume: ${{ secrets.AWS_CI_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}

- name: Install node dependencies
run: npm ci

- name: Deploy with Serverless Framework
env:
ENV: ${{ inputs.environment }}
CONCURRENCY: ${{ inputs.provisionedConcurrency }}
run: npm run deploy
64 changes: 64 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

# VS Code settings
.vscode/settings.json
Loading

0 comments on commit 9df9835

Please sign in to comment.