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

[nodejs] Enable DI PII and probe status tests #3802

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
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
15 changes: 12 additions & 3 deletions manifests/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,20 @@ tests/:
test_debugger_expression_language.py:
Test_Debugger_Expression_Language: missing_feature (feature not implented)
test_debugger_pii.py:
Test_Debugger_PII_Redaction: missing_feature (feature not implented)
Test_Debugger_PII_Redaction:
"*": irrelevant
express4: v5.31.0
express4-typescript: v5.31.0
test_debugger_probe_snapshot.py:
Test_Debugger_Probe_Snaphots: missing_feature (feature not implented)
Test_Debugger_Probe_Snaphots:
"*": irrelevant
express4: v5.32.0
express4-typescript: v5.32.0
test_debugger_probe_status.py:
Test_Debugger_Probe_Statuses: missing_feature (feature not implented)
Test_Debugger_Probe_Statuses:
"*": irrelevant
express4: v5.32.0
express4-typescript: v5.32.0
integrations/:
crossed_integrations/:
test_kafka.py:
Expand Down
39 changes: 0 additions & 39 deletions tests/debugger/probes/probe_status_log.json

This file was deleted.

15 changes: 15 additions & 0 deletions tests/debugger/probes/probe_status_log_line.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{
"language": "",
"type": "",
"id": "loga0cf2-line-45cf-9f39-59installed",
"version": 0,
"where": {
"typeName": null,
"sourceFile": "ACTUAL_SOURCE_FILE",
"lines": [
"20"
]
}
}
]
26 changes: 26 additions & 0 deletions tests/debugger/probes/probe_status_log_method.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"language": "",
"type": "",
"id": "loga0cf2-meth-45cf-9f39-591received",
"version": 0,
"where": {
"typeName": "NotReallyExists",
"methodName": "SomeMethod",
"sourceFile": null
},
"evaluateAt": "EXIT"
},
{
"language": "",
"type": "",
"id": "loga0cf2-meth-45cf-9f39-59installed",
"version": 0,
"where": {
"typeName": "ACTUAL_TYPE_NAME",
"methodName": "LogProbe",
"sourceFile": null
},
"evaluateAt": "EXIT"
}
]
1 change: 1 addition & 0 deletions tests/debugger/test_debugger_pii.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def setup_pii_redaction_method_full(self):
@bug(context.library == "[email protected]", reason="DEBUG-3127")
@bug(context.library == "[email protected]", reason="DEBUG-3127")
@missing_feature(context.library == "ruby", reason="Local variable capture not implemented for method probes")
@missing_feature(context.library == "nodejs", reason="Not yet implemented")
def test_pii_redaction_method_full(self):
self._assert(REDACTED_KEYS, REDACTED_TYPES)

Expand Down
21 changes: 17 additions & 4 deletions tests/debugger/test_debugger_probe_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,23 @@ def _check_probe_status(expected_id, expected_status):

assert not errors, f"Probe status errors:\n" + "\n".join(errors)

############ log probe ############
def setup_probe_status_log(self):
self._setup("probe_status_log")
############ log line probe ############
def setup_probe_status_log_line(self):
self._setup("probe_status_log_line")

@bug(context.library == "[email protected]", reason="DEBUG-3127")
@bug(context.library == "[email protected]", reason="DEBUG-3127")
def test_probe_status_log(self):
def test_probe_status_log_line(self):
self._assert()

############ log method probe ############
def setup_probe_status_log_method(self):
self._setup("probe_status_log_method")

@bug(context.library == "[email protected]", reason="DEBUG-3127")
@bug(context.library == "[email protected]", reason="DEBUG-3127")
@missing_feature(context.library == "nodejs", reason="Not yet implemented")
def test_probe_status_log_method(self):
self._assert()

############ metric probe ############
Expand All @@ -76,6 +86,7 @@ def setup_probe_status_metric(self):
@bug(context.library == "[email protected]", reason="DEBUG-3127")
@bug(context.library == "[email protected]", reason="DEBUG-3127")
@missing_feature(context.library == "ruby", reason="Not yet implemented")
@missing_feature(context.library == "nodejs", reason="Not yet implemented")
def test_probe_status_metric(self):
self._assert()

Expand All @@ -84,6 +95,7 @@ def setup_probe_status_span(self):
self._setup("probe_status_span")

@missing_feature(context.library == "ruby", reason="Not yet implemented")
@missing_feature(context.library == "nodejs", reason="Not yet implemented")
def test_probe_status_span(self):
self._assert()

Expand All @@ -94,5 +106,6 @@ def setup_probe_status_spandecoration(self):
@bug(context.library == "[email protected]", reason="DEBUG-3127")
@bug(context.library == "[email protected]", reason="DEBUG-3127")
@missing_feature(context.library == "ruby", reason="Not yet implemented")
@missing_feature(context.library == "nodejs", reason="Not yet implemented")
def test_probe_status_spandecoration(self):
self._assert()
2 changes: 2 additions & 0 deletions tests/debugger/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def __get_probe_type(probe_id):
probe["where"]["sourceFile"] = "debugger_controller.py"
elif language == "ruby":
probe["where"]["sourceFile"] = "debugger_controller.rb"
elif language == "nodejs":
probe["where"]["sourceFile"] = "debugger/log_handler.js"
probe["type"] = __get_probe_type(probe["id"])

return probes
Expand Down
4 changes: 4 additions & 0 deletions utils/build/docker/nodejs/express/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const crypto = require('crypto')

const iast = require('./iast')
const dsm = require('./dsm')
const di = require('./debugger')

const { spawnSync } = require('child_process')

const pgsql = require('./integrations/db/postgres')
Expand Down Expand Up @@ -436,6 +438,8 @@ app.get('/createextraservice', (req, res) => {

iast.initRoutes(app, tracer)

di.initRoutes(app, tracer)

require('./auth')(app, passport, tracer)

// try to flush as much stuff as possible from the library
Expand Down
9 changes: 9 additions & 0 deletions utils/build/docker/nodejs/express/debugger/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'

const logHandler = require('./log_handler')

module.exports = {
initRoutes (app, tracer) {
app.get('/log', logHandler)
}
}
21 changes: 21 additions & 0 deletions utils/build/docker/nodejs/express/debugger/log_handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict'

// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding

module.exports = function logHandler (req, res) {
res.send('Log probe') // This needs to be line 20
}
3 changes: 3 additions & 0 deletions utils/build/docker/nodejs/express4-typescript/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const multer = require('multer')
const uploadToMemory = multer({ storage: multer.memoryStorage(), limits: { fileSize: 200000 } })

const iast = require('./iast')
const di = require('./debugger')

iast.initData().catch(() => {})

Expand All @@ -29,6 +30,8 @@ iast.initMiddlewares(app)
require('./auth')(app, passport, tracer)
iast.initRoutes(app)

di.initRoutes(app)

app.get('/', (req: Request, res: Response) => {
console.log('Received a request');
res.send('Hello\n');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Express } from 'express'
import { logHandler } from './log_handler'

export function initRoutes (app: Express) {
app.get('/log', logHandler)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Request, Response } from 'express'

// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding
// Padding

export function logHandler (req: Request, res: Response) {
res.send('Log probe') // This needs to be line 20
}
Loading