Skip to content

Commit b4d004d

Browse files
authored
[AppSec] esbuild support for IAST (esm) (#6821)
1 parent 315020a commit b4d004d

File tree

17 files changed

+274
-83
lines changed

17 files changed

+274
-83
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import './init.mjs'
2+
3+
import express from 'express'
4+
5+
import iastRouter from './iast/index.mjs'
6+
7+
const app = express()
8+
9+
app.use('/iast', iastRouter)
10+
11+
const server = app.listen(0, () => {
12+
process.send?.({ port: server.address().port })
13+
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* eslint-disable no-console */
2+
3+
import path from 'node:path'
4+
import { fileURLToPath } from 'node:url'
5+
6+
import esbuild from 'esbuild'
7+
8+
import esbuildCommonConfig from './esbuild.common-config.mjs'
9+
10+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
11+
const outfile = path.join(__dirname, 'build', 'iast-disabled.mjs')
12+
13+
esbuild.build({
14+
...esbuildCommonConfig,
15+
outfile,
16+
sourcemap: false
17+
}).catch((err) => {
18+
console.error(err)
19+
process.exit(1)
20+
})
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import path from 'node:path'
2+
import { fileURLToPath } from 'node:url'
3+
4+
import ddPlugin from 'dd-trace/esbuild.js'
5+
6+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
7+
const entryPoint = path.join(__dirname, 'app.mjs')
8+
9+
export default {
10+
entryPoints: [entryPoint],
11+
bundle: true,
12+
minify: false,
13+
format: 'esm',
14+
plugins: [ddPlugin],
15+
platform: 'node',
16+
target: ['node18'],
17+
external: [
18+
'@datadog/native-iast-taint-tracking',
19+
'@datadog/wasm-js-rewriter',
20+
21+
// required if you encounter graphql errors during the build step
22+
// see https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#bundling
23+
'graphql/language/visitor',
24+
'graphql/language/printer',
25+
'graphql/utilities'
26+
]
27+
}

0 commit comments

Comments
 (0)