Skip to content

Conversation

@haesbaert
Copy link
Collaborator

@haesbaert haesbaert commented May 14, 2025

This implements the 12 byte entity id as defined in https://www.elastic.co/docs/reference/ecs/ecs-process#field-process-entity-id

We can't depend on dynamic linking of md or openssl, so include a standlone MIT licensed sha256 implementation from https://github.com/ilvn/SHA256, they claim to be formally verified, so that's something.

We now also have to link against resolv so we can get the base64 functions, that's ok, beats already links against it.

This is a WIP as I want to make sure we compute the very same entity_id as gosysinfo and friends.

    Implement entity_id. Issue #155

    This implements entity id as defined in
    https://www.elastic.co/docs/reference/ecs/ecs-process#field-process-entity-id

    I don't want to link with libresolv just to get b64_ntop, so include our own
    portable version (musl also doesn't have it).

    Entity id's only requirement is to be unique, so use pid number + boot time,
    which should be enough.

@haesbaert
Copy link
Collaborator Author

haesbaert commented May 14, 2025

I think I can use a weak symbol from md or openssl, it seems they both provide strong symbols, so by including ours as a weak symbol it should work as a fallback.
Also, no b64_ntop in musl, so have to provide one.

@haesbaert
Copy link
Collaborator Author

I've decided to go for a stupidly simple entity_id, the only requirement is too be unique, so pid + boot time should be enough in linux, no point in trying to match other implementations as everyone does differently anyway.

@haesbaert haesbaert marked this pull request as ready for review July 21, 2025 09:20
@haesbaert haesbaert requested a review from a team as a code owner July 21, 2025 09:20
@haesbaert haesbaert force-pushed the entity_id branch 2 times, most recently from d5ec11a to 8175572 Compare July 21, 2025 09:23
quark.c Outdated
}

static void
process_entity_id(struct quark_queue *qq, struct quark_process *qp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see qq being used. Nuke it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I adapted from the old code and didn't realize it, will zap it.

This implements entity id as defined in
https://www.elastic.co/docs/reference/ecs/ecs-process#field-process-entity-id

I don't want to link with libresolv just to get b64_ntop, so include our own
portable version (musl also doesn't have it).

Entity id's only requirement is to be unique, so use pid number + boot time,
which should be enough.
Copy link
Contributor

@nicholasberlin nicholasberlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@haesbaert haesbaert merged commit 73df6b8 into main Jul 21, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants