Skip to content

Commit 0ea38b4

Browse files
committed
security suggestions
1 parent 0dab9b3 commit 0ea38b4

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

dev-packages/e2e-tests/test-applications/aws-lambda-sam/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
},
1212
"//": "We just need the AWS layer zip file, not the NPM package",
1313
"devDependencies": {
14-
"@sentry/aws-serverless": "link:../../../../packages/aws-serverless/build/aws/dist-serverless/",
1514
"@aws-sdk/client-lambda": "^3.863.0",
1615
"@playwright/test": "~1.53.2",
1716
"@sentry-internal/test-utils": "link:../../../test-utils",
17+
"@sentry/aws-serverless": "link:../../../../packages/aws-serverless/build/aws/dist-serverless/",
18+
"@types/tmp": "^0.2.6",
1819
"aws-cdk-lib": "^2.210.0",
1920
"constructs": "^10.4.2",
20-
"glob": "^11.0.3"
21+
"glob": "^11.0.3",
22+
"tmp": "^0.2.5"
2123
},
2224
"volta": {
2325
"extends": "../../package.json"

dev-packages/e2e-tests/test-applications/aws-lambda-sam/stack.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as os from 'node:os';
66
import * as dns from 'node:dns/promises';
77
import { platform } from 'node:process';
88
import { globSync } from 'glob';
9-
import { execSync } from 'node:child_process';
9+
import { execFileSync } from 'node:child_process';
1010

1111
const LAMBDA_FUNCTIONS_WITH_LAYER_DIR = './lambda-functions-layer';
1212
const LAMBDA_FUNCTIONS_WITH_NPM_DIR = './lambda-functions-npm';
@@ -70,7 +70,7 @@ export class LocalLambdaStack extends Stack {
7070
console.log(`[LocalLambdaStack] Install dependencies for ${functionName}`);
7171
const packageJson = { dependencies: { '@sentry/aws-serverless': '* || latest' } };
7272
fs.writeFileSync(path.join(functionsDir, lambdaDir, 'package.json'), JSON.stringify(packageJson, null, 2));
73-
execSync(`npm install --prefix ${path.join(functionsDir, lambdaDir)}`);
73+
execFileSync('npm', ['install', '--prefix', path.join(functionsDir, lambdaDir)], { stdio: 'inherit' });
7474
}
7575

7676
const isEsm = fs.existsSync(path.join(functionsDir, lambdaDir, 'index.mjs'));

dev-packages/e2e-tests/test-applications/aws-lambda-sam/tests/lambda.test.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { test as base, expect } from '@playwright/test';
22
import { waitForTransaction } from '@sentry-internal/test-utils';
33
import { App } from 'aws-cdk-lib';
4+
import * as tmp from 'tmp';
45
import { LocalLambdaStack, SAM_PORT, getHostIp } from '../stack.js';
5-
import { writeFileSync, openSync } from 'node:fs';
6-
import { tmpdir } from 'node:os';
7-
import * as path from 'node:path';
6+
import { writeFileSync } from 'node:fs';
87
import { spawn, execSync } from 'node:child_process';
98
import { InvokeCommand, LambdaClient } from '@aws-sdk/client-lambda';
109

@@ -26,9 +25,8 @@ const test = base.extend<{ testEnvironment: LocalLambdaStack; lambdaClient: Lamb
2625
const template = app.synth().getStackByName('LocalLambdaStack').template;
2726
writeFileSync(SAM_TEMPLATE_FILE, JSON.stringify(template, null, 2));
2827

29-
const debugLogFile = path.join(tmpdir(), 'sentry_aws_lambda_tests_sam_debug.log');
30-
const debugLogFd = openSync(debugLogFile, 'w');
31-
console.log(`[test_environment fixture] Writing SAM debug log to: ${debugLogFile}`);
28+
const debugLog = tmp.fileSync({ prefix: 'sentry_aws_lambda_tests_sam_debug_', postfix: '.log' });
29+
console.log(`[test_environment fixture] Writing SAM debug log to: ${debugLog.name}`);
3230

3331
const process = spawn(
3432
'sam',
@@ -44,7 +42,7 @@ const test = base.extend<{ testEnvironment: LocalLambdaStack; lambdaClient: Lamb
4442
DOCKER_NETWORK_NAME,
4543
],
4644
{
47-
stdio: ['ignore', debugLogFd, debugLogFd],
45+
stdio: ['ignore', debugLog.fd, debugLog.fd],
4846
},
4947
);
5048

0 commit comments

Comments
 (0)