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: support configure egg.revert in package.json #252

Merged
merged 2 commits into from
Feb 19, 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
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
with:
os: 'ubuntu-latest, macos-latest'
version: '14, 16, 18'
version: '14, 16, 18, 20'
8 changes: 8 additions & 0 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ class Command extends BaseCommand {
execArgvObj.require = execArgvObj.require.concat(eggInfo.require);
}

if (eggInfo.revert) {
context.execArgvObj['security-revert'] = context.execArgvObj['security-revert'] || [];
const reverts = Array.isArray(eggInfo.revert) ? eggInfo.revert : [ eggInfo.revert ];
for (const revert of reverts) {
context.execArgvObj['security-revert'].push(revert);
}
}

// load ts-node
if (argv.typescript) {
execArgvObj.require.push(argv.tscompiler);
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/egg-revert/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "demo-app",
"egg": {
"framework": "aliyun-egg",
"revert": "CVE-2023-46809"
}
}
5 changes: 5 additions & 0 deletions test/fixtures/egg-revert/test/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('test/index.test.js', () => {
it('should test', () => {
// test
});
});
13 changes: 13 additions & 0 deletions test/lib/cmd/dev.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const coffee = require('coffee');
const net = require('net');
const mm = require('mm');
const detect = require('detect-port');
const version = Number(process.version.substring(1, 3));

describe('test/lib/cmd/dev.test.js', () => {
const eggBin = require.resolve('../../../bin/egg-bin.js');
Expand Down Expand Up @@ -175,4 +176,16 @@ describe('test/lib/cmd/dev.test.js', () => {
.expect('code', 0)
.end();
});

it('should support egg.revert', () => {
if (version < 18) return;
mm(process.env, 'NODE_ENV', 'development');
return coffee.fork(eggBin, [ 'dev' ], {
cwd: path.join(__dirname, '../../fixtures/egg-revert'),
})
// .debug()
.expect('stdout', /SECURITY WARNING: Reverting CVE-2023-46809: Marvin attack on PKCS#1 padding/)
.expect('code', 0)
.end();
});
});
12 changes: 12 additions & 0 deletions test/lib/cmd/test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const mm = require('mm');
const assert = require('assert');
const changed = require('jest-changed-files');
const Command = require('../../../lib/cmd/test');
const version = Number(process.version.substring(1, 3));

describe('test/lib/cmd/test.test.js', () => {
const eggBin = require.resolve('../../../bin/egg-bin.js');
Expand Down Expand Up @@ -300,4 +301,15 @@ describe('test/lib/cmd/test.test.js', () => {
.expect('code', 1)
.end();
});

it('should support egg.revert', () => {
if (version < 18) return;
return coffee.fork(eggBin, [ 'test' ], {
cwd: path.join(__dirname, '../../fixtures/egg-revert'),
})
.debug()
.expect('stdout', /SECURITY WARNING: Reverting CVE-2023-46809: Marvin attack on PKCS#1 padding/)
.expect('code', 0)
.end();
});
});
Loading