-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
usm: tls: nodejs: Introduce NodeJS TLS support for USM (#24285)
* usm: configuration: Added a feature flag to enable node js TLS monitoring * usm: tls: generalize SSL_read_ex and SSL_write_ex Moving the shared implementation into helper functions, to allow reuse by other probes like nodejs, istio, and on. Similar to the change introduced in commit '765c48d' * usm: tls: Introduce NodeJS TLS tag and counter Adding to the kernel a TLS tag for NodeJS to be used for marking the connections as NodeJS TLS connections. Also, in the usermode, introducing a dedicated counter for NodeJS TLS connections. * usm: tls: nodejs: Implement skeleton of nodejs monitor Introducing the skeleton of the nodejs monitor, which registers on process creation and termination, looks for relevant processes (by verifying the executable path contains '/bin/node'), and on the matching processes, applies SSL hooks * usm: tls: nodejs: Run nodejs monitor The change is initializing the nodejs monitoring and launch it. * usm: tls: nodejs: tests: Added UT for capturing HTTPs over nodejs * releasenotes: Added release notes for the new feature * Fixed CR notes * Fixed python server
- Loading branch information
Showing
21 changed files
with
607 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ enum static_tags { | |
JAVA_TLS = (1<<3), | ||
CONN_TLS = (1<<4), | ||
ISTIO = (1<<5), | ||
NODEJS = (1<<6), | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
// Package nodejs provides helpers to run nodejs HTTPs server. | ||
package nodejs | ||
|
||
import ( | ||
"io" | ||
"os" | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/DataDog/datadog-agent/pkg/network/protocols/http/testutil" | ||
protocolsUtils "github.com/DataDog/datadog-agent/pkg/network/protocols/testutil" | ||
) | ||
|
||
func copyFile(src, dst string) error { | ||
source, err := os.Open(src) | ||
if err != nil { | ||
return err | ||
} | ||
defer source.Close() | ||
|
||
destination, err := os.Create(dst) | ||
if err != nil { | ||
return err | ||
} | ||
defer destination.Close() | ||
|
||
_, err = io.Copy(destination, source) | ||
return err | ||
} | ||
|
||
func linkFile(t *testing.T, src, dst string) error { | ||
t.Helper() | ||
_ = os.Remove(dst) | ||
if err := copyFile(src, dst); err != nil { | ||
return err | ||
} | ||
t.Cleanup(func() { os.Remove(dst) }) | ||
return nil | ||
} | ||
|
||
// RunServerNodeJS launches an HTTPs server written in NodeJS. | ||
func RunServerNodeJS(t *testing.T, key, cert, serverPort string) error { | ||
t.Helper() | ||
dir, _ := testutil.CurDir() | ||
if err := linkFile(t, key, dir+"/testdata/certs/srv.key"); err != nil { | ||
return err | ||
} | ||
if err := linkFile(t, cert, dir+"/testdata/certs/srv.crt"); err != nil { | ||
return err | ||
} | ||
env := []string{ | ||
"ADDR=0.0.0.0", | ||
"PORT=" + serverPort, | ||
"CERTS_DIR=/v/certs", | ||
"TESTDIR=" + dir + "/testdata", | ||
} | ||
return protocolsUtils.RunDockerServer(t, "nodejs-server", dir+"/testdata/docker-compose.yml", env, regexp.MustCompile("Server running at https.*"), protocolsUtils.DefaultTimeout, 3) | ||
} | ||
|
||
// GetNodeJSDockerPID returns the PID of the nodejs docker container. | ||
func GetNodeJSDockerPID() (int64, error) { | ||
return protocolsUtils.GetDockerPID("node-node-1") | ||
} |
Empty file.
13 changes: 13 additions & 0 deletions
13
pkg/network/protocols/tls/nodejs/testdata/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: '3' | ||
name: node | ||
services: | ||
node: | ||
image: node:lts-alpine3.19 | ||
command: ["node", "/v/server.js"] | ||
ports: | ||
- ${PORT}:4141 | ||
environment: | ||
- ADDR | ||
- CERTS_DIR | ||
volumes: | ||
- ${TESTDIR}:/v:z |
Oops, something went wrong.