Skip to content

Commit

Permalink
Applied changes from branch upgrade-incl-redis minus redis parts
Browse files Browse the repository at this point in the history
  • Loading branch information
binarymist committed Mar 21, 2022
1 parent f05a4cb commit 4a1ab44
Show file tree
Hide file tree
Showing 30 changed files with 3,929 additions and 4,894 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git/
.github/
.gitignore
.husky/
.vscode/
vscode-workspaces/
.eslint*

20 changes: 7 additions & 13 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,17 @@ module.exports = {
// enforce consistent line breaks inside function parentheses
// https://eslint.org/docs/rules/function-paren-newline
'function-paren-newline': ['error', 'multiline'],
'import/no-unresolved': ['error', { commonjs: true }],
// Eslint can't deal with ESM modules currently.
'import/no-unresolved': ['error', { ignore: ['purpleteam-logger'] }],
// Used in order to supress the errors in the use of appending file extensions to the import statement for local modules
// Which is required in order to upgrade from CJS to ESM. At time of upgrade file extensions have to be provided in import statements.
'import/extensions': ['error', { 'js': 'ignorePackages' }],
'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }],
'object-curly-newline': ['error', { multiline: true }],
'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 0, maxEOF: 1 }],
'newline-per-chained-call': 'off',
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }]
},
env: { node: true },
parserOptions: { ecmaVersion: 2021 },
parser: 'babel-eslint', // required for private class members as eslint only supports ECMA Stage 4, will be able to remove in the future
settings: {
'import/resolver': {
node: {
paths: [
`${process.cwd()}`
]
}
}
}
env: { node: true, 'es2021': true },
parserOptions: { sourceType: 'module', ecmaVersion: 'latest' }
};
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ RUN cd $WORKDIR && npm install
#RUN apk del .gyp python make g++
#USER $USER

# String expansion doesn't work currently: https://github.com/moby/moby/issues/35018
# COPY --chown=${USER}:GROUP . $WORKDIR
COPY --chown=orchestrator:purpleteam . $WORKDIR
# String expansion didn't used to work currently: https://github.com/moby/moby/issues/35018
COPY --chown=${USER}:${GROUP} . $WORKDIR

# Here I used to chown and chmod as shown here: http://f1.holisticinfosecforwebdevelopers.com/chap03.html#vps-countermeasures-docker-the-default-user-is-root
# Problem is, each of these commands creates another layer of all the files modified and thus adds over 100MB to the image: https://www.datawire.io/not-engineer-running-3-5gb-docker-images/
Expand Down
15 changes: 9 additions & 6 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0

const convict = require('convict');
const { duration } = require('convict-format-with-moment');
const { url } = require('convict-format-with-validator');
const path = require('path');
import convict from 'convict';
import { duration } from 'convict-format-with-moment';
import { url } from 'convict-format-with-validator';
import { fileURLToPath } from 'url';
import path, { dirname } from 'path';

convict.addFormat(duration);
convict.addFormat(url);
Expand Down Expand Up @@ -203,7 +204,9 @@ const schema = {
};

const config = convict(schema);
config.loadFile(path.join(__dirname, `config.${process.env.NODE_ENV}.json`));
const filename = fileURLToPath(import.meta.url);
const currentDirName = dirname(filename);
config.loadFile(path.join(currentDirName, `config.${process.env.NODE_ENV}.json`));
config.validate();

module.exports = config;
export default config;
25 changes: 9 additions & 16 deletions healthcheck.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
// Copyright (C) 2017-2021 BinaryMist Limited. All rights reserved.
// Copyright (C) 2017-2022 BinaryMist Limited. All rights reserved.

// This file is part of PurpleTeam.
// Use of this software is governed by the Business Source License
// included in the file /licenses/bsl.md

// PurpleTeam is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation version 3.
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0

// PurpleTeam is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.

// You should have received a copy of the GNU Affero General Public License
// along with PurpleTeam. If not, see <https://www.gnu.org/licenses/>.

const http = require('http');
require('convict');
const config = require('./config/config');
import http from 'http';
import 'convict';
import config from './config/config.js';

const options = {
host: config.get('host.host'),
Expand Down
22 changes: 7 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
// Copyright (C) 2017-2021 BinaryMist Limited. All rights reserved.
// Copyright (C) 2017-2022 BinaryMist Limited. All rights reserved.

// This file is part of PurpleTeam.
// Use of this software is governed by the Business Source License
// included in the file /licenses/bsl.md

// PurpleTeam is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation version 3.
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0

// PurpleTeam is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.

// You should have received a copy of the GNU Affero General Public License
// along with PurpleTeam. If not, see <https://www.gnu.org/licenses/>.

require('app-module-path/register');
const server = require('src/server');
import server from './src/server.js';

const init = async () => {
await server.registerPlugins();
Expand Down
Loading

0 comments on commit 4a1ab44

Please sign in to comment.