Skip to content

Commit 4a1ab44

Browse files
committed
Applied changes from branch upgrade-incl-redis minus redis parts
1 parent f05a4cb commit 4a1ab44

30 files changed

+3929
-4894
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.git/
2+
.github/
3+
.gitignore
4+
.husky/
5+
.vscode/
6+
vscode-workspaces/
7+
.eslint*
8+

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,17 @@ module.exports = {
2424
// enforce consistent line breaks inside function parentheses
2525
// https://eslint.org/docs/rules/function-paren-newline
2626
'function-paren-newline': ['error', 'multiline'],
27-
'import/no-unresolved': ['error', { commonjs: true }],
27+
// Eslint can't deal with ESM modules currently.
28+
'import/no-unresolved': ['error', { ignore: ['purpleteam-logger'] }],
29+
// Used in order to supress the errors in the use of appending file extensions to the import statement for local modules
30+
// Which is required in order to upgrade from CJS to ESM. At time of upgrade file extensions have to be provided in import statements.
31+
'import/extensions': ['error', { 'js': 'ignorePackages' }],
2832
'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }],
2933
'object-curly-newline': ['error', { multiline: true }],
3034
'no-multiple-empty-lines': ['error', { max: 2, maxBOF: 0, maxEOF: 1 }],
3135
'newline-per-chained-call': 'off',
3236
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }]
3337
},
34-
env: { node: true },
35-
parserOptions: { ecmaVersion: 2021 },
36-
parser: 'babel-eslint', // required for private class members as eslint only supports ECMA Stage 4, will be able to remove in the future
37-
settings: {
38-
'import/resolver': {
39-
node: {
40-
paths: [
41-
`${process.cwd()}`
42-
]
43-
}
44-
}
45-
}
38+
env: { node: true, 'es2021': true },
39+
parserOptions: { sourceType: 'module', ecmaVersion: 'latest' }
4640
};

.husky/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ RUN cd $WORKDIR && npm install
7070
#RUN apk del .gyp python make g++
7171
#USER $USER
7272

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

7776
# Here I used to chown and chmod as shown here: http://f1.holisticinfosecforwebdevelopers.com/chap03.html#vps-countermeasures-docker-the-default-user-is-root
7877
# 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/

config/config.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
// the Business Source License, use of this software will be governed
88
// by the Apache License, Version 2.0
99

10-
const convict = require('convict');
11-
const { duration } = require('convict-format-with-moment');
12-
const { url } = require('convict-format-with-validator');
13-
const path = require('path');
10+
import convict from 'convict';
11+
import { duration } from 'convict-format-with-moment';
12+
import { url } from 'convict-format-with-validator';
13+
import { fileURLToPath } from 'url';
14+
import path, { dirname } from 'path';
1415

1516
convict.addFormat(duration);
1617
convict.addFormat(url);
@@ -203,7 +204,9 @@ const schema = {
203204
};
204205

205206
const config = convict(schema);
206-
config.loadFile(path.join(__dirname, `config.${process.env.NODE_ENV}.json`));
207+
const filename = fileURLToPath(import.meta.url);
208+
const currentDirName = dirname(filename);
209+
config.loadFile(path.join(currentDirName, `config.${process.env.NODE_ENV}.json`));
207210
config.validate();
208211

209-
module.exports = config;
212+
export default config;

healthcheck.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
1-
// Copyright (C) 2017-2021 BinaryMist Limited. All rights reserved.
1+
// Copyright (C) 2017-2022 BinaryMist Limited. All rights reserved.
22

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

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

9-
// PurpleTeam is distributed in the hope that it will be useful,
10-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
// GNU Affero General Public License for more details.
13-
14-
// You should have received a copy of the GNU Affero General Public License
15-
// along with PurpleTeam. If not, see <https://www.gnu.org/licenses/>.
16-
17-
const http = require('http');
18-
require('convict');
19-
const config = require('./config/config');
10+
import http from 'http';
11+
import 'convict';
12+
import config from './config/config.js';
2013

2114
const options = {
2215
host: config.get('host.host'),

index.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
// Copyright (C) 2017-2021 BinaryMist Limited. All rights reserved.
1+
// Copyright (C) 2017-2022 BinaryMist Limited. All rights reserved.
22

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

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

9-
// PurpleTeam is distributed in the hope that it will be useful,
10-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
// GNU Affero General Public License for more details.
13-
14-
// You should have received a copy of the GNU Affero General Public License
15-
// along with PurpleTeam. If not, see <https://www.gnu.org/licenses/>.
16-
17-
require('app-module-path/register');
18-
const server = require('src/server');
10+
import server from './src/server.js';
1911

2012
const init = async () => {
2113
await server.registerPlugins();

0 commit comments

Comments
 (0)