Skip to content

Commit

Permalink
Add dependabot and eslint actions
Browse files Browse the repository at this point in the history
  • Loading branch information
nielm committed Nov 27, 2023
1 parent 3327539 commit 534ba5d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 6 deletions.
20 changes: 20 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Worth setting up DependaBot for this? It's just one YAML file away :)

.github/dependabot.yaml:

---
updates:
- directory: "/"
package-ecosystem: "github-actions"
schedule:
interval: "daily"
- directory: "/cloudrun-malware-scanner"
package-ecosystem: "npm"
schedule:
interval: "daily"
- directory: "/cloudrun-malware-scanner"
package-ecosystem: "docker"
schedule:
interval: "daily"
version: 2
...
37 changes: 37 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "ESLint"

on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]

jobs:
analyze:
name: "Eslint-analyze"
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODEJS_VERSION }}
check-latest: true
always-auth: true

# Install eslint
- name: Install eslint
working-directory: cloudrun-malware-scanner/
run: npm install eslint eslint-config-google

- name: Run eslint
working-directory: cloudrun-malware-scanner/
run: npm run eslint
2 changes: 1 addition & 1 deletion cloudrun-malware-scanner/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = {
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 2020
},
"rules": {
}
Expand Down
13 changes: 10 additions & 3 deletions cloudrun-malware-scanner/gcs-proxy-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const {logger} = require('./logger.js');
// eslint-disable-next-line no-unused-vars
const {Config, readAndVerifyConfig} = require('./config.js');
const httpProxy = require('http-proxy');
const {nextTick} = require('process');

const TOKEN_REFRESH_THRESHOLD_MILLIS = 60000;

Expand Down Expand Up @@ -49,7 +48,7 @@ async function accessTokenRefresh() {
new Date().getTime() + TOKEN_REFRESH_THRESHOLD_MILLIS) {
accessToken = await googleAuth.getAccessToken();
logger.info(`Access token expires at ${
new Date(client.credentials.expiry_date).toISOString()}`);
new Date(client.credentials.expiry_date).toISOString()}`);
}
const nextCheckDate =
new Date(client.credentials.expiry_date - TOKEN_REFRESH_THRESHOLD_MILLIS);
Expand All @@ -61,6 +60,10 @@ async function accessTokenRefresh() {

/**
* Handle any internal proxy errors by returning a 500
*
* @param {!Error} err
* @param {!IncomingMessage} req The request payload
* @param {!ServerResponse} res The HTTP response object
*/
function handleProxyError(err, req, res) {
logger.error(
Expand All @@ -73,6 +76,10 @@ function handleProxyError(err, req, res) {

/**
* Handle proxy requests - check path, and add Authorization header.
*
* @param {!Request} proxyReq
* @param {!IncomingMessage} req The request payload
* @param {!ServerResponse} res The HTTP response object
*/
function handleProxyReq(proxyReq, req, res) {
if (proxyReq.path.startsWith('/' + clamCvdMirrorBucket + '/')) {
Expand Down Expand Up @@ -107,7 +114,7 @@ async function setupGcsReverseProxy() {

proxy.listen(PROXY_PORT, 'localhost');
logger.info(`GCS authenticating reverse proxy listenting on port ${
PROXY_PORT} for requests to ${clamCvdMirrorBucket}`);
PROXY_PORT} for requests to ${clamCvdMirrorBucket}`);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions cloudrun-malware-scanner/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 534ba5d

Please sign in to comment.