Skip to content

Commit

Permalink
move to fixtures and clean gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Aug 9, 2024
1 parent 7190436 commit 04d76e9
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 60 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
some-file.txt.*
some-file-promises.txt.*
some-file-promisify.txt.*
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const app = express();

app.get('/readFile-error', async (_, res) => {
try {
await fs.promises.readFile(path.join(__dirname, 'some-file-that-doesnt-exist.txt'), 'utf-8');
await fs.promises.readFile(path.join(__dirname, 'fixtures', 'some-file-that-doesnt-exist.txt'), 'utf-8');
} catch {
// noop
}
Expand All @@ -34,51 +34,59 @@ app.get('/readFile-error', async (_, res) => {

app.get('/readFile', async (_, res) => {
await new Promise<void>(resolve => {
fs.readFile(path.join(__dirname, 'some-file.txt'), 'utf-8', () => {
fs.readFile(path.join(__dirname, 'fixtures', 'some-file.txt'), 'utf-8', () => {
resolve();
});
});
await fs.promises.readFile(path.join(__dirname, 'some-file-promises.txt'), 'utf-8');
await util.promisify(fs.readFile)(path.join(__dirname, 'some-file-promisify.txt'), 'utf-8');
await fs.promises.readFile(path.join(__dirname, 'fixtures', 'some-file-promises.txt'), 'utf-8');
await util.promisify(fs.readFile)(path.join(__dirname, 'fixtures', 'some-file-promisify.txt'), 'utf-8');
res.send('done');
});

app.get('/copyFile', async (_, res) => {
await new Promise<void>(resolve => {
fs.copyFile(path.join(__dirname, 'some-file.txt'), path.join(__dirname, 'some-file.txt.copy'), () => {
resolve();
});
fs.copyFile(
path.join(__dirname, 'fixtures', 'some-file.txt'),
path.join(__dirname, 'fixtures', 'some-file.txt.copy'),
() => {
resolve();
},
);
});
await fs.promises.copyFile(
path.join(__dirname, 'some-file-promises.txt'),
path.join(__dirname, 'some-file-promises.txt.copy'),
path.join(__dirname, 'fixtures', 'some-file-promises.txt'),
path.join(__dirname, 'fixtures', 'some-file-promises.txt.copy'),
);
await util.promisify(fs.copyFile)(
path.join(__dirname, 'some-file-promisify.txt'),
path.join(__dirname, 'some-file-promisify.txt.copy'),
path.join(__dirname, 'fixtures', 'some-file-promisify.txt'),
path.join(__dirname, 'fixtures', 'some-file-promisify.txt.copy'),
);
res.send('done');
});

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
a file system access
, but is not rate-limited.
This route handler performs
a file system access
, but is not rate-limited.

app.get('/link', async (_, res) => {
await new Promise<void>(resolve => {
fs.link(path.join(__dirname, 'some-file.txt'), path.join(__dirname, 'some-file.txt.link'), () => {
resolve();
});
fs.link(
path.join(__dirname, 'fixtures', 'some-file.txt'),
path.join(__dirname, 'fixtures', 'some-file.txt.link'),
() => {
resolve();
},
);
});
await fs.promises.link(
path.join(__dirname, 'some-file-promises.txt'),
path.join(__dirname, 'some-file-promises.txt.link'),
path.join(__dirname, 'fixtures', 'some-file-promises.txt'),
path.join(__dirname, 'fixtures', 'some-file-promises.txt.link'),
);
await util.promisify(fs.link)(
path.join(__dirname, 'some-file-promisify.txt'),
path.join(__dirname, 'some-file-promisify.txt.link'),
path.join(__dirname, 'fixtures', 'some-file-promisify.txt'),
path.join(__dirname, 'fixtures', 'some-file-promisify.txt.link'),
);

await Promise.all([
fs.promises.unlink(path.join(__dirname, 'some-file.txt.link')),
fs.promises.unlink(path.join(__dirname, 'some-file-promises.txt.link')),
fs.promises.unlink(path.join(__dirname, 'some-file-promisify.txt.link')),
fs.promises.unlink(path.join(__dirname, 'fixtures', 'some-file.txt.link')),
fs.promises.unlink(path.join(__dirname, 'fixtures', 'some-file-promises.txt.link')),
fs.promises.unlink(path.join(__dirname, 'fixtures', 'some-file-promisify.txt.link')),
]);

res.send('done');
Expand All @@ -98,23 +106,27 @@ app.get('/mkdtemp', async (_, res) => {

app.get('/symlink', async (_, res) => {
await new Promise<void>(resolve => {
fs.symlink(path.join(__dirname, 'some-file.txt'), path.join(__dirname, 'some-file.txt.symlink'), () => {
resolve();
});
fs.symlink(
path.join(__dirname, 'fixtures', 'some-file.txt'),
path.join(__dirname, 'fixtures', 'some-file.txt.symlink'),
() => {
resolve();
},
);
});
await fs.promises.symlink(
path.join(__dirname, 'some-file-promises.txt'),
path.join(__dirname, 'some-file-promises.txt.symlink'),
path.join(__dirname, 'fixtures', 'some-file-promises.txt'),
path.join(__dirname, 'fixtures', 'some-file-promises.txt.symlink'),
);
await util.promisify(fs.symlink)(
path.join(__dirname, 'some-file-promisify.txt'),
path.join(__dirname, 'some-file-promisify.txt.symlink'),
path.join(__dirname, 'fixtures', 'some-file-promisify.txt'),
path.join(__dirname, 'fixtures', 'some-file-promisify.txt.symlink'),
);

await Promise.all([
fs.promises.unlink(path.join(__dirname, 'some-file.txt.symlink')),
fs.promises.unlink(path.join(__dirname, 'some-file-promises.txt.symlink')),
fs.promises.unlink(path.join(__dirname, 'some-file-promisify.txt.symlink')),
fs.promises.unlink(path.join(__dirname, 'fixtures', 'some-file.txt.symlink')),
fs.promises.unlink(path.join(__dirname, 'fixtures', 'some-file-promises.txt.symlink')),
fs.promises.unlink(path.join(__dirname, 'fixtures', 'some-file-promisify.txt.symlink')),
]);

res.send('done');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test('should create spans for fs operations that take target argument', done =>
status: 'unknown_error',
data: {
fs_error: expect.stringMatching('ENOENT: no such file or directory,'),
path_argument: expect.stringMatching('/some-file-that-doesnt-exist.txt'),
path_argument: expect.stringMatching('/fixtures/some-file-that-doesnt-exist.txt'),
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'file',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.file.fs',
},
Expand All @@ -41,7 +41,7 @@ test('should create spans for fs operations that take one path', done => {
op: 'file',
status: 'ok',
data: {
path_argument: expect.stringMatching('/some-file.txt'),
path_argument: expect.stringMatching('/fixtures/some-file.txt'),
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'file',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.file.fs',
},
Expand All @@ -51,7 +51,7 @@ test('should create spans for fs operations that take one path', done => {
op: 'file',
status: 'ok',
data: {
path_argument: expect.stringMatching('/some-file-promises.txt'),
path_argument: expect.stringMatching('/fixtures/some-file-promises.txt'),
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'file',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.file.fs',
},
Expand All @@ -61,7 +61,7 @@ test('should create spans for fs operations that take one path', done => {
op: 'file',
status: 'ok',
data: {
path_argument: expect.stringMatching('/some-file-promisify.txt'),
path_argument: expect.stringMatching('/fixtures/some-file-promisify.txt'),
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'file',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.file.fs',
},
Expand All @@ -85,8 +85,8 @@ test('should create spans for fs operations that take src and dest arguments', d
op: 'file',
status: 'ok',
data: {
src_argument: expect.stringMatching('/some-file.txt'),
dest_argument: expect.stringMatching('/some-file.txt.copy'),
src_argument: expect.stringMatching('/fixtures/some-file.txt'),
dest_argument: expect.stringMatching('/fixtures/some-file.txt.copy'),
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'file',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.file.fs',
},
Expand All @@ -96,8 +96,8 @@ test('should create spans for fs operations that take src and dest arguments', d
op: 'file',
status: 'ok',
data: {
src_argument: expect.stringMatching('/some-file-promises.txt'),
dest_argument: expect.stringMatching('/some-file-promises.txt.copy'),
src_argument: expect.stringMatching('/fixtures/some-file-promises.txt'),
dest_argument: expect.stringMatching('/fixtures/some-file-promises.txt.copy'),
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'file',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.file.fs',
},
Expand All @@ -107,8 +107,8 @@ test('should create spans for fs operations that take src and dest arguments', d
op: 'file',
status: 'ok',
data: {
src_argument: expect.stringMatching('/some-file-promisify.txt'),
dest_argument: expect.stringMatching('/some-file-promisify.txt.copy'),
src_argument: expect.stringMatching('/fixtures/some-file-promisify.txt'),
dest_argument: expect.stringMatching('/fixtures/some-file-promisify.txt.copy'),
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'file',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.file.fs',
},
Expand All @@ -132,8 +132,8 @@ test('should create spans for fs operations that take existing path and new path
op: 'file',
status: 'ok',
data: {
existing_path_argument: expect.stringMatching('/some-file.txt'),
new_path_argument: expect.stringMatching('/some-file.txt.link'),
existing_path_argument: expect.stringMatching('/fixtures/some-file.txt'),
new_path_argument: expect.stringMatching('/fixtures/some-file.txt.link'),
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'file',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.file.fs',
},
Expand All @@ -154,8 +154,8 @@ test('should create spans for fs operations that take existing path and new path
op: 'file',
status: 'ok',
data: {
existing_path_argument: expect.stringMatching('/some-file-promisify.txt'),
new_path_argument: expect.stringMatching('/some-file-promisify.txt.link'),
existing_path_argument: expect.stringMatching('/fixtures/some-file-promisify.txt'),
new_path_argument: expect.stringMatching('/fixtures/some-file-promisify.txt.link'),
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'file',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.file.fs',
},
Expand Down Expand Up @@ -234,8 +234,8 @@ test('should create spans for fs operations that take target argument', done =>
op: 'file',
status: 'ok',
data: {
target_argument: expect.stringMatching('/some-file-promisify.txt'),
path_argument: expect.stringMatching('/some-file-promisify.txt.symlink'),
target_argument: expect.stringMatching('/fixtures/some-file-promisify.txt'),
path_argument: expect.stringMatching('/fixtures/some-file-promisify.txt.symlink'),
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'file',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.file.fs',
},
Expand All @@ -245,8 +245,8 @@ test('should create spans for fs operations that take target argument', done =>
op: 'file',
status: 'ok',
data: {
target_argument: expect.stringMatching('/some-file-promisify.txt'),
path_argument: expect.stringMatching('/some-file-promisify.txt.symlink'),
target_argument: expect.stringMatching('/fixtures/some-file-promisify.txt'),
path_argument: expect.stringMatching('/fixtures/some-file-promisify.txt.symlink'),
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'file',
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.file.fs',
},
Expand Down

0 comments on commit 04d76e9

Please sign in to comment.