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

Add fleet-vulnerability-dashboard repo to ee/ folder #17428

Merged
merged 5 commits into from
Mar 13, 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
79 changes: 79 additions & 0 deletions .github/workflows/deploy-vulnerability-dashboard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Deploy app to vulnerability dashboard pipeline on Heroku.

on:
push:
branches: [ main ]
paths:
- 'ee/vulnerability-dashboard/**'

jobs:
build:
if: ${{ github.repository == 'fleetdm/fleet' }}

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

# Configure our access credentials for the Heroku CLI
- uses: akhileshns/heroku-deploy@79ef2ae4ff9b897010907016b268fd0f88561820 # v3.6.8
with:
heroku_api_key: ${{secrets.HEROKU_API_TOKEN_FOR_DEPLOYMENT}}
heroku_app_name: "" # this has to be blank or it doesn't work
heroku_email: ${{secrets.HEROKU_EMAIL_FOR_DEPLOYMENT}}
justlogin: true
- run: heroku auth:whoami

# Set the Node.js version
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: ${{ matrix.node-version }}

# Now start building!
# > …but first, get a little crazy for a sec and delete the top-level package.json file
# > i.e. the one used by the Fleet server. This is because require() in node will go
# > hunting in ancestral directories for missing dependencies, and since some of the
# > bundled transpiler tasks sniff for package availability using require(), this trips
# > up when it encounters another Node universe in the parent directory.
- run: rm -rf package.json package-lock.json node_modules/
# > Turns out there's a similar issue with how eslint plugins are looked up, so we
# > delete the top level .eslintrc file too.
- run: rm -f .eslintrc.js
# > And, as a change to the top-level fleetdm/fleet .gitignore on May 2, 2022 revealed,
# > we also need to delete the top level .gitignore file too, so that its rules don't
# > interfere with the committing and force-pushing we're doing as part of our deploy
# > script here. For more info, see: https://github.com/fleetdm/fleet/pull/5549
- run: rm -f .gitignore

# Get dependencies (including dev deps)
- run: cd ee/vulnerability-dashboard/ && npm install

# Run sanity checks
- run: cd ee/vulnerability-dashboard/ && npm test

# Compile assets
- run: cd ee/vulnerability-dashboard/ && npm run build-for-prod

# Commit newly-built assets locally so we can push them to Heroku below.
# (This commit will never be pushed to GitHub- only to Heroku.)
# > The local config flags make this work in GitHub's environment.
- run: git add ee/vulnerability-dashboard/.www
- run: git -c "user.name=GitHub" -c "user.email=github@example.com" commit -am 'AUTOMATED COMMIT - Deployed the latest, including modified HTML layouts and .sailsrc file that reference minified assets.'

# Configure the Heroku app we'll be deploying to
- run: heroku git:remote -a vulnerability-dashboard
- run: git remote -v

# Deploy to Heroku (by pushing)
# > Since a shallow clone was grabbed, we have to "unshallow" it before forcepushing.
- run: echo "Unshallowing local repository…"
- run: git fetch --prune --unshallow
- run: echo "Deploying branch '${GITHUB_REF##*/}' to Heroku…"
- run: git push heroku +${GITHUB_REF##*/}:master
- name: 🌐 The dashboard has been deployed
run: echo '' && echo '--' && echo 'OK, done. It should be live momentarily.' && echo '(if you get impatient, check the Heroku dashboard for status)'
50 changes: 50 additions & 0 deletions .github/workflows/test-vulnerability-dashboard-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
on:
pull_request:
paths:
- 'ee/vulnerability-dashboard/**'
- '.github/workflows/test-vulnerability-dashboard-changes.yml'

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id}}
cancel-in-progress: true

jobs:
build:
permissions:
contents: read
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

# Set the Node.js version
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version: ${{ matrix.node-version }}


# Now start building!
# > …but first, get a little crazy for a sec and delete the top-level package.json file
# > i.e. the one used by the Fleet server. This is because require() in node will go
# > hunting in ancestral directories for missing dependencies, and since some of the
# > bundled transpiler tasks sniff for package availability using require(), this trips
# > up when it encounters another Node universe in the parent directory.
- run: rm -rf package.json package-lock.json node_modules/
# > Turns out there's a similar issue with how eslint plugins are looked up, so we
# > delete the top level .eslintrc file too.
- run: rm -f .eslintrc.js

# Get dependencies (including dev deps)
- run: cd ee/vulnerability-dashboard/ && npm install

# Run sanity checks
- run: cd ee/vulnerability-dashboard/ && npm test

# Compile assets
- run: cd ee/vulnerability-dashboard/ && npm run build-for-prod
31 changes: 31 additions & 0 deletions ee/vulnerability-dashboard/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
################################################
# ╔═╗╔╦╗╦╔╦╗╔═╗╦═╗┌─┐┌─┐┌┐┌┌─┐┬┌─┐
# ║╣ ║║║ ║ ║ ║╠╦╝│ │ ││││├┤ ││ ┬
# o╚═╝═╩╝╩ ╩ ╚═╝╩╚═└─┘└─┘┘└┘└ ┴└─┘
#
# > Formatting conventions for your Sails app.
#
# This file (`.editorconfig`) exists to help
# maintain consistent formatting throughout the
# files in your Sails app.
#
# For the sake of convention, the Sails team's
# preferred settings are included here out of the
# box. You can also change this file to fit your
# team's preferences (for example, if all of the
# developers on your team have a strong preference
# for tabs over spaces),
#
# To review what each of these options mean, see:
# http://editorconfig.org/
#
################################################
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
3 changes: 3 additions & 0 deletions ee/vulnerability-dashboard/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
assets/dependencies/**/*.js
views/**/*.ejs

98 changes: 98 additions & 0 deletions ee/vulnerability-dashboard/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
// ╔═╗╔═╗╦ ╦╔╗╔╔╦╗┬─┐┌─┐
// ║╣ ╚═╗║ ║║║║ ║ ├┬┘│
// o╚═╝╚═╝╩═╝╩╝╚╝ ╩ ┴└─└─┘
// A set of basic code conventions designed to encourage quality and consistency
// across your Sails app's code base. These rules are checked against
// automatically any time you run `npm test`.
//
// > An additional eslintrc override file is included in the `assets/` folder
// > right out of the box. This is specifically to allow for variations in acceptable
// > global variables between front-end JavaScript code designed to run in the browser
// > vs. backend code designed to run in a Node.js/Sails process.
//
// > Note: If you're using mocha, you'll want to add an extra override file to your
// > `test/` folder so that eslint will tolerate mocha-specific globals like `before`
// > and `describe`.
// Designed for ESLint v4.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// For more information about any of the rules below, check out the relevant
// reference page on eslint.org. For example, to get details on "no-sequences",
// you would visit `http://eslint.org/docs/rules/no-sequences`. If you're unsure
// or could use some advice, come by https://sailsjs.com/support.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

"env": {
"node": true,
"es6": true
},

"parserOptions": {
"ecmaVersion": 2018
},

"globals": {
// If "no-undef" is enabled below, be sure to list all global variables that
// are used in this app's backend code (including the globalIds of models):
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Promise": true,
"sails": true,
"_": true,

// Models:
"User": true,
"Platform": true,
"Vulnerability": true,
"VulnerabilityInstall": true,
"SoftwareVersion": true,
"SoftwareVersionInstall": true,
"Host": true,
"OperatingSystem": true,
"CriticalInstall": true,
// …and any others.
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
},

"rules": {
"block-scoped-var": ["error"],
"callback-return": ["error", ["done", "proceed", "next", "onwards", "callback", "cb"]],
"camelcase": ["warn", {"properties":"always"}],
"comma-style": ["warn", "last"],
"curly": ["warn"],
"eqeqeq": ["error", "always"],
"eol-last": ["warn"],
"handle-callback-err": ["error"],
"indent": ["warn", 2, {
"SwitchCase": 1,
"MemberExpression": "off",
"FunctionDeclaration": {"body":1, "parameters":"off"},
"FunctionExpression": {"body":1, "parameters":"off"},
"CallExpression": {"arguments":"off"},
"ArrayExpression": 1,
"ObjectExpression": 1,
"ignoredNodes": ["ConditionalExpression"]
}],
"linebreak-style": ["error", "unix"],
"no-dupe-keys": ["error"],
"no-duplicate-case": ["error"],
"no-extra-semi": ["warn"],
"no-labels": ["error"],
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"no-redeclare": ["warn"],
"no-return-assign": ["error", "always"],
"no-sequences": ["error"],
"no-trailing-spaces": ["warn"],
"no-undef": ["error"],
"no-unexpected-multiline": ["warn"],
"no-unreachable": ["warn"],
"no-unused-vars": ["warn", {"caughtErrors":"all", "caughtErrorsIgnorePattern": "^unused($|[A-Z].*$)", "argsIgnorePattern": "^unused($|[A-Z].*$)", "varsIgnorePattern": "^unused($|[A-Z].*$)" }],
"no-use-before-define": ["error", {"functions":false}],
"one-var": ["warn", "never"],
"prefer-arrow-callback": ["warn", {"allowNamedFunctions":true}],
"quotes": ["warn", "single", {"avoidEscape":false, "allowTemplateLiterals":true}],
"semi": ["warn", "always"],
"semi-spacing": ["warn", {"before":false, "after":true}],
"semi-style": ["warn", "last"]
}

}
Loading
Loading