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

update 4x branch 20240513 #4022

Merged
merged 26 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a431333
release: add provenance with GitHub actions (#3938)
v1v Apr 26, 2024
68807a5
chore(deps): bump @opentelemetry/exporter-prometheus (#3988)
dependabot[bot] Apr 29, 2024
2b5db31
chore(deps): bump react-dom (#3990)
dependabot[bot] Apr 29, 2024
af3afea
chore(deps-dev): bump the eslint group with 2 updates (#3992)
dependabot[bot] Apr 29, 2024
abc07cc
chore(deps-dev): bump tedious from 18.1.0 to 18.2.0 (#3995)
dependabot[bot] Apr 29, 2024
e35e4c9
chore(deps-dev): bump undici from 6.13.0 to 6.14.1 (#3996)
dependabot[bot] Apr 29, 2024
c9a4a22
chore(deps): bump react (#3991)
dependabot[bot] Apr 29, 2024
321bbfa
chore(deps): bump @opentelemetry/sdk-metrics from 1.23.0 to 1.24.0 (#…
dependabot[bot] Apr 29, 2024
b45e57d
test: test with Node.js v22 (#3999)
trentm Apr 30, 2024
71c344d
chore(deps-dev): bump the eslint group with 2 updates (#4001)
dependabot[bot] May 6, 2024
6108940
chore(deps-dev): bump mongodb from 6.5.0 to 6.6.0 (#4003)
dependabot[bot] May 6, 2024
641f0de
chore(deps-dev): bump undici from 6.14.1 to 6.15.0 (#4002)
dependabot[bot] May 6, 2024
23b6673
chore(deps): bump import-in-the-middle from 1.7.3 to 1.7.4 (#4004)
dependabot[bot] May 6, 2024
46a5fe2
chore(deps-dev): bump eslint-plugin-n in the eslint group (#4008)
dependabot[bot] May 13, 2024
d670269
chore(deps-dev): bump mongodb from 6.6.0 to 6.6.1 (#4009)
dependabot[bot] May 13, 2024
9d69fd7
chore(deps): bump @opentelemetry/core from 1.24.0 to 1.24.1 (#4010)
dependabot[bot] May 13, 2024
d74c0d7
chore(deps): bump pino from 8.17.1 to 8.21.0 (#4011)
dependabot[bot] May 13, 2024
07d8333
chore(deps-dev): bump fastify from 4.26.2 to 4.27.0 (#4012)
dependabot[bot] May 13, 2024
b027652
chore(deps-dev): bump undici from 6.15.0 to 6.16.1 (#4013)
dependabot[bot] May 13, 2024
6e6597e
chore(deps-dev): bump azure-functions-core-tools (#4017)
dependabot[bot] May 13, 2024
9c4e84a
chore(deps): bump @opentelemetry/sdk-metrics from 1.24.0 to 1.24.1 (#…
dependabot[bot] May 13, 2024
630a4aa
chore(deps): bump @opentelemetry/sdk-metrics to 1.24.1 in test fixtur…
dependabot[bot] May 13, 2024
5b620b5
chore(deps): bump @opentelemetry/exporter-prometheus (#4016)
dependabot[bot] May 13, 2024
4e508e2
ci: use docker/metadata-action to gather tags/labels (#3998)
v1v May 13, 2024
dcec828
fix: change how 'cookie' header is represented in trans to avoid poss…
trentm May 13, 2024
05b0f2f
release 4.5.4 (#4018)
trentm May 13, 2024
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
16 changes: 0 additions & 16 deletions .ci/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
SHELL = /bin/bash -eo pipefail
MAKEFLAGS += --no-print-directory
AWS_FOLDER = ../build/aws
DIST_DIR = /build/dist/nodejs
LAMBDA_LAYER_ZIP_FILE = ../build/dist/elastic-apm-node-lambda-layer.zip
DOCKER_IMAGE_NAME = observability/apm-agent-nodejs
DOCKER_REGISTRY = docker.elastic.co
SUFFIX_ARN_FILE = arn-file.md
AGENT_VERSION = $(subst v,,$(GITHUB_REF_NAME))
MAJOR_VERSION = $(shell cut -d '.' -f 1 <<< $(AGENT_VERSION))
Expand Down Expand Up @@ -35,14 +32,6 @@ clean:
env:
@env | sort

# Create Docker image
build-docker: validate-version
docker build -t $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(AGENT_VERSION) \
--build-arg AGENT_DIR=$(DIST_DIR) ..

push-docker: build-docker
../dev-utils/push-docker.sh $(DOCKER_REGISTRY) $(DOCKER_IMAGE_NAME) $(AGENT_VERSION)

# List all the AWS regions
get-all-aws-regions:
@mkdir -p $(AWS_FOLDER)
Expand Down Expand Up @@ -99,11 +88,6 @@ create-arn-file: validate-release-notes-url
github-release: validate-ref-name
../dev-utils/github-release.sh "$(GITHUB_REF_NAME)" "$(AWS_FOLDER)/$(SUFFIX_ARN_FILE)"

validate-version:
ifndef AGENT_VERSION
$(error AGENT_VERSION is undefined)
endif

validate-ref-name:
ifndef GITHUB_REF_NAME
$(error GITHUB_REF_NAME is undefined)
Expand Down
2 changes: 1 addition & 1 deletion .ci/tav.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"versions": [ "21", "20", "18", "16", "14" ],
"versions": [ "22", "20", "18", "16", "14" ],
"// modules": [
"List of instrumented modules with the minimum Node major version supported.",
"minMajorVersion for each module should be kept in sync with .tav.yml"
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/edge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [ "22" ]
node: [ "23" ]
steps:
- uses: actions/checkout@v4
- run: .ci/scripts/test.sh -b "nightly" "${{ matrix.node }}"
Expand All @@ -50,7 +50,8 @@ jobs:
fail-fast: false
matrix:
node:
- "21"
- "23"
- "22"
- "20"
- "18"
steps:
Expand Down
56 changes: 50 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ on:
push:
tags:
- v*.*.*
branches:
- main

permissions:
attestations: write
contents: write
id-token: write
pull-requests: read

jobs:
release:
runs-on: ubuntu-latest
env:
DOCKER_IMAGE_NAME: docker.elastic.co/observability/apm-agent-nodejs
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -33,7 +39,41 @@ jobs:

- run: make -C .ci dist

- run: make -C .ci push-docker
- name: Attest Lambda layer zip
uses: github-early-access/generate-build-provenance@main
with:
subject-path: "${{ github.workspace }}/build/aws/elastic-apm-node-lambda-layer-*.zip"

- name: Extract metadata (tags, labels)
id: docker-meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ env.DOCKER_IMAGE_NAME }}
flavor: |
latest=auto
tags: |
# "1.2.3" and "latest" Docker tags on push of git tag "v1.2.3"
type=semver,pattern={{version}}
# "edge" Docker tag on git push to default branch
type=edge

- name: Build and Push Docker Image
id: docker-push
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
context: .
push: true
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
build-args: |
AGENT_DIR=/build/dist/nodejs

- name: Attest Docker image
uses: github-early-access/generate-build-provenance@main
with:
subject-name: "${{ env.DOCKER_IMAGE_NAME }}"
subject-digest: ${{ steps.docker-push.outputs.digest }}
push-to-registry: true

- name: Read AWS vault secrets
uses: hashicorp/vault-action@v3.0.0
Expand All @@ -46,12 +86,15 @@ jobs:
secret/observability-team/ci/service-account/apm-aws-lambda access_key_id | AWS_ACCESS_KEY_ID ;
secret/observability-team/ci/service-account/apm-aws-lambda secret_access_key | AWS_SECRET_ACCESS_KEY

- name: Publish AWS lambda
- name: Publish AWS lambda (only for tag release)
if: startsWith(github.ref, 'refs/tags')
run: make -C .ci publish-in-all-aws-regions create-arn-file
env:
GH_TOKEN: ${{ github.token }}

- run: make -C .ci github-release
- name: create github release (only for tag release)
run: make -C .ci github-release
if: startsWith(github.ref, 'refs/tags')
env:
GH_TOKEN: ${{ github.token }}

Expand All @@ -66,12 +109,13 @@ jobs:
secret/jenkins-ci/npmjs/elasticmachine token | NPMJS_TOKEN ;
totp/code/npmjs-elasticmachine code | TOTP_CODE

- name: npm publish
- name: npm publish (only for tag release)
if: startsWith(github.ref, 'refs/tags')
run: |-
echo "//registry.npmjs.org/:_authToken=${{ env.NPMJS_TOKEN }}" > .npmrc
npm publish --otp=${{ env.TOTP_CODE }}
npm publish --otp=${{ env.TOTP_CODE }} --provenance

- if: always()
- if: ${{ always() && startsWith(github.ref, 'refs/tags') }}
uses: elastic/apm-pipeline-library/.github/actions/notify-build-status@current
with:
vaultUrl: ${{ secrets.VAULT_ADDR }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
- "2181:2181"
volumes:
- nodezookeeperdata:/var/lib/zookeeper/data

kafka:
image: bitnami/kafka:3.3.2
ports:
Expand All @@ -154,8 +154,8 @@ jobs:
fail-fast: false
matrix:
node:
- '21'
- '21.0'
- '22'
- '22.0'
- '20'
- '20.0'
- '18'
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,38 @@ Notes:

See the <<upgrade-to-v4>> guide.

[[release-notes-4.5.4]]
==== 4.5.4 - 2024/05/13

[float]
===== Bug fixes

- Change how the "cookie" HTTP request header is represented in APM transaction
data to avoid a rare, but possible, intake bug where the transaction could be
rejected due to a mapping conflict.

Before this change a `Cookie: foo=bar; sessionid=42` HTTP request header
would be represented in the transaction document in Elasticsearch with these
document fields (the example assumes <<sanitize-field-names>> matches
"sessionid", as it does by default):

```
http.request.headers.cookie: "[REDACTED]"
...
http.request.cookies.foo: "bar"
http.request.cookies.sessionid: "[REDACTED]"
```

After this change it is represented as:

```
http.request.headers.cookie: "foo=bar; sessionid=REDACTED"
```

In other words, `http.request.cookies` are no longer separated out.
({issues}4006[#4006])


[[release-notes-4.5.3]]
==== 4.5.3 - 2024/04/23

Expand Down
32 changes: 0 additions & 32 deletions dev-utils/push-docker.sh

This file was deleted.

5 changes: 3 additions & 2 deletions lib/filters/sanitize-field-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@ function redactKeysFromPostedFormVariables(body, requestHeaders, regexes) {
*
* @param {Object} obj The source object be copied with redacted fields
* @param {Array<RegExp>} regexes RegExps to check if the entry value needd to be redacted
* @param {String} redactedStr The string to use for redacted values. Defaults to '[REDACTED]'.
* @returns {Object} Copy of the source object with REDACTED entries or the original if falsy or regexes is not an array
*/
function redactKeysFromObject(obj, regexes) {
function redactKeysFromObject(obj, regexes, redactedStr = REDACTED) {
if (!obj || !Array.isArray(regexes)) {
return obj;
}
const result = {};
for (const key of Object.keys(obj)) {
const shouldRedact = regexes.some((regex) => regex.test(key));
result[key] = shouldRedact ? REDACTED : obj[key];
result[key] = shouldRedact ? redactedStr : obj[key];
}
return result;
}
Expand Down
28 changes: 22 additions & 6 deletions lib/parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ const {
redactKeysFromPostedFormVariables,
} = require('./filters/sanitize-field-names');

// When redacting individual cookie field values, this string is used instead
// of `[REDACTED]`. The APM spec says:
// > The replacement string SHOULD be `[REDACTED]`.
// We diverge from spec here because, for better or worse, the `cookie` module
// does `encodeURIComponent/decodeURIComponent` encoding on cookie fields. If we
// used the brackets, then the reconstructed cookie would look like
// `foo=bar; session-id=%5BREDACTED%5D`, which isn't helpful.
const COOKIE_VAL_REDACTED = 'REDACTED';

/**
* Extract appropriate `{transaction,error}.context.request` from an HTTP
* request object. This handles header and body capture and redaction
Expand Down Expand Up @@ -61,14 +70,21 @@ function getContextFromRequest(req, conf, type) {
conf.sanitizeFieldNamesRegExp,
);

if (context.headers.cookie) {
context.cookies = cookie.parse(req.headers.cookie);
context.cookies = redactKeysFromObject(
context.cookies,
if (context.headers.cookie && context.headers.cookie !== REDACTED) {
let cookies = cookie.parse(req.headers.cookie);
cookies = redactKeysFromObject(
cookies,
conf.sanitizeFieldNamesRegExp,
COOKIE_VAL_REDACTED,
);
// Redact the cookie to avoid data duplication
context.headers.cookie = REDACTED;
try {
context.headers.cookie = Object.keys(cookies)
.map((k) => cookie.serialize(k, cookies[k]))
.join('; ');
} catch (_err) {
// Fallback to full redaction if there is an issue re-serializing.
context.headers.cookie = REDACTED;
}
}
}

Expand Down
Loading