Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create github action to wait for discovery to finish #1

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
dist
_*
.eslintrc.js
244 changes: 244 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
module.exports = {
root: true,
env: {
es6: true,
node: true
},
extends: [
'prettier',
'eslint:recommended',
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/eslint-recommended'
],
ignorePatterns: [
'**/test{,s}',
'**/*.spec.ts'
],
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts']
},
'import/resolver': {
typescript: {}
}
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['tsconfig.json'],
tsconfigRootDir: __dirname
},
plugins: ['@typescript-eslint', 'import'],
rules: {
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
accessibility: 'explicit',
overrides: {
accessors: 'no-public',
constructors: 'no-public'
}
}
],
'@typescript-eslint/consistent-indexed-object-style': ['error', 'record'],
'@typescript-eslint/member-ordering': [
'error',
{
default: [
// Static fields
'public-static-field',
'protected-static-field',
'private-static-field',

// Instance fields
'public-instance-field',
'protected-instance-field',
'private-instance-field',

// Constructors
'constructor',

// Methods
'public-static-method',
'protected-static-method',
'private-static-method',
'public-instance-method',
'protected-instance-method',
'private-instance-method'
]
}
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'forbid',
trailingUnderscore: 'forbid'
},
{
selector: 'enumMember',
format: ['UPPER_CASE']
},
{
selector: 'typeLike',
format: ['PascalCase']
},
{
selector: 'function',
format: ['PascalCase', 'camelCase']
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase', 'snake_case']
},
{
selector: 'method',
format: ['camelCase', 'PascalCase'],
modifiers: ['static']
},
{
selector: 'property',
format: ['camelCase', 'UPPER_CASE', 'PascalCase', 'snake_case'],
leadingUnderscore: 'allow'
},
// https://github.com/typescript-eslint/typescript-eslint/issues/1510#issuecomment-580593245
{
selector: 'parameter',
format: ['camelCase'],
leadingUnderscore: 'allow'
}
],
'@typescript-eslint/no-inferrable-types': [
'error',
{
ignoreParameters: true,
ignoreProperties: true
}
],
'@typescript-eslint/default-param-last': ['error'],
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/unified-signatures': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/typedef': [
'error',
{
arrayDestructuring: true,
arrowParameter: false,
memberVariableDeclaration: false,
variableDeclarationIgnoreFunction: true
}
],
'@typescript-eslint/no-shadow': [
'error',
{
hoist: 'all'
}
],
'arrow-body-style': 'error',
'camelcase': 'off',
'complexity': [
'error',
{
max: 10
}
],
'eqeqeq': ['error', 'smart'],
'guard-for-in': 'error',
'import/no-self-import': 'error',
'import/no-absolute-path': 'error',
'import/no-duplicates': 'error',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: false,
optionalDependencies: false,
peerDependencies: false
}
],
'import/no-useless-path-segments': [
'error',
{
noUselessIndex: true
}
],
'import/order': [
'error',
{
groups: [
'index',
['sibling', 'parent'],
'internal',
'external',
'builtin'
]
}
],
'max-classes-per-file': ['error', 1],
'max-depth': [
'error',
{
max: 2
}
],
'default-param-last': 'off',
'no-bitwise': 'error',
'no-caller': 'error',
'no-console': 'error',
'no-eval': 'error',
'no-restricted-syntax': ['error', 'ForInStatement'],
'no-throw-literal': 'error',
'no-undef-init': 'error',
'object-shorthand': 'error',
'one-var': ['error', 'never'],
'padding-line-between-statements': [
'error',
{
blankLine: 'always',
next: 'return',
prev: '*'
}
],
'prefer-arrow-callback': 'error',
'prefer-const': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'radix': 'error'
},
overrides: [
{
env: {
mocha: true
},
files: ['*.spec.ts'],
parserOptions: {
project: ['./tsconfig.spec.json'],
tsconfigRootDir: __dirname
},
rules: {
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: ['**/*.spec.ts'] }
],
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'chai',
importNames: ['should'],
message: "Please `import 'chai/register-should'` instead"
}
]
}
]
}
}
]
};
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release
on:
push:
branches:
- master

jobs:
build:
name: Build GitHub Action
runs-on: ubuntu-latest
container: node:20
steps:
- name: Install packages
run: |
apt-get update
apt-get install -y rsync
- uses: actions/checkout@v3
- name: Install dependencies
run: npm ci -q
- name: Build release
run: |
npm run lint
npm run build
npm run pack
- name: Copy files to release
run: |
mkdir release
cp LICENSE release/
cp README.md release/
cp action.yml release/
cp -R dist/ release/dist/
- name: Push changes to the branch
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
branch: release
folder: release
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI / Automated testing

on:
pull_request:
branches:
- '**'

jobs:
build:
name: Build GitHub Action
runs-on: ubuntu-latest
container: node:20
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: npm ci && npm install -g @vercel/ncc
- name: Build release
run: npm run lint && npm run build && npm run pack
- name: Copy files to release
run: |
mkdir release
cp README.md release/
cp action.yml release/
cp -R dist/ release/dist/
- name: Start Bright Discovery 🏁
id: discovery
uses: NeuraLegion/run-discovery@release
with:
api_token: ${{ secrets.BRIGHTSEC_TOKEN }}
name: GitHub discovery ${{ github.sha }}
project_id: ${{ vars.PROJECT_ID }}
hostname: ${{ vars.HOSTNAME }}
discovery_types: |
[ "crawler" ]
crawler_urls: |
[ "https://security-crawl-maze.app/html/body/form" ]
hosts_filter: |
[ ]
- name: Wait for discovery to finish ⏳
id: wait
uses: ./release
continue-on-error: true
with:
api_token: ${{ secrets.BRIGHTSEC_TOKEN }}
discovery_id: ${{ steps.discovery.outputs.id }}
project_id: ${{ vars.PROJECT_ID }}
hostname: ${{ vars.HOSTNAME }}
timeout: 360 # in general cases we'll have a timeout and it is good for this test

12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
node_modules/
dist
.clinic
.idea
.DS_Store
.vs
.vscode
.stfolder
.env
.secrets
*.code-workspace
_*
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/post-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

git update-index --again
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged --relative
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
assets
node_modules
*-lock.json
*.lock
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"tabWidth": 2,
"singleQuote": true,
"bracketSpacing": true,
"printWidth": 80,
"trailingComma": "none",
"arrowParens": "avoid",
"quoteProps": "consistent"
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Bright Security
Copyright (c) 2022 Bright Security Inc. All Rights Reserved

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading
Loading