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

Add orchestrator (resource.parent.type and resource.ip) and container (image.hash.all) fields #1889

Merged
merged 9 commits into from
May 2, 2022

Conversation

daniel-almeida
Copy link
Contributor

@daniel-almeida daniel-almeida commented Apr 20, 2022

  • Have you signed the contributor license agreement? yes
  • Have you followed the contributor guidelines? yes
  • For proposing substantial changes or additions to the schema, have you reviewed the RFC process? yes
  • If submitting code/script changes, have you verified all tests pass locally using make test? N/A
  • If submitting schema/fields updates, have you generated new artifacts by running make and committed those changes?yes
  • Is your pull request against main? Unless there is a good reason otherwise, we prefer pull requests against main and will backport as needed. yes
  • Have you added an entry to the CHANGELOG.next.md? yes

@daniel-almeida daniel-almeida marked this pull request as ready for review April 21, 2022 15:14
@daniel-almeida daniel-almeida requested a review from a team as a code owner April 21, 2022 15:14
Copy link
Member

@ebeahan ebeahan left a comment

Choose a reason for hiding this comment

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

Changes look good, @daniel-almeida. I just had a few thoughts about the naming.

Thanks for adding the changelog.next entry!

@daniel-almeida daniel-almeida requested a review from ebeahan April 25, 2022 18:00
Copy link
Member

@ebeahan ebeahan left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +6446 to +6447
Note: this field should contain an array of values.

Choose a reason for hiding this comment

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

should be put a caveat comment for Pods. E.g. "In the case of Kubernetes Pods, there will be one IP address in this array"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This note was auto-generated. I updated the long description to cover that as well.



example: `DaemonSet`

Choose a reason for hiding this comment

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

ideally we would enumerate the values we currently expect along with whether they are case-sensitive etc. This will help sensor writers. Perhaps we could reference a Kube docs page for the list of 'nouns' and standard spelling & capitalization.

Comment on lines 900 to 901
- name: image.hash.sha256
level: extended
Copy link

@m-sample m-sample Apr 26, 2022

Choose a reason for hiding this comment

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

by having a separate field for each hash type (sha256, ....) we will need to update ECS for every new hash alg in use (e.g. "blake3" becomes popular next year). There may be an expectation that all of them are populated (ie we compute them vs just scooping the one from the Kube API).

Pardon the last minute observation on this but this approach seems very maintenance heavy (us) vs just having "<hashalg>:<b64 of hash>" as the value's structure for image.hash field. This approach keeps it to one field to look in and automatically supports new hash algs, and parsing isn't that hard - most folks will be looking for an equality match, I suspect so they could type "sha256:ab1234ace..." for their search.

Copy link
Member

Choose a reason for hiding this comment

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

I understand that perspective, and I'm fine if we decide on image.hash.

My thinking around container.image.hash.sha256:

  • Follow the naming convention used by the hash.* field set and its reuses, like file.hash.sha256.
  • If the related.* fields are being populated, related.hash helps simplify searching across the different hash fields.
  • Avoid establishing image.hash as a leaf field

Copy link

@m-sample m-sample Apr 26, 2022

Choose a reason for hiding this comment

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

interesting. related.hash as an array of all the hash values doesn't seem to help as there would only be 1 entry in the array and it wouldn't be self-describing (could be sha256, sha512, ?).

I agree we should not overload "hash" to be a the existing field set or this new primitive valued one :head-explode:.

How does this sound: Add a field to the "hash" field set, something like hash.all that holds an array of self-describing hash values like <hash-alg>:<b64-hash-bytes>. Sort of related.hash but co-located with hash field set and self-describing. This would accommodate the current case of 1 hash value read from the kube API, as well as possible future use cases where we populate the different hash algs values too. Allowed values for the hash-alg part would be the existing field names in the hash fieldset? Thankfully they seem to align with Kubernetes use of "sha256" (same as ECS field name).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mike, just to clarify: you're suggesting both fields (hash.sha256 and hash.all) should be set by producers, right?

Copy link

@m-sample m-sample Apr 27, 2022

Choose a reason for hiding this comment

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

Just hash.all to start. Rationale: keep our events DRY (no duplicated information in an event) to save on bandwidth and storage.

Copy link
Member

Choose a reason for hiding this comment

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

Works for me 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we meant to say container.image... instead of orchestrator.image.... Just pushed that change; let me know if it's good to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ebeahan , I noticed that hash values in the TLS field set you referenced are capitalized for consistency. Should we do the same here?

Copy link
Member

Choose a reason for hiding this comment

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

@daniel-almeida, ECS field names are always lowercase. Is that what you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I meant the [hash] values. If you look at https://www.elastic.co/guide/en/ecs/current/ecs-tls.html#field-tls-client-hash-sha256, you will notice that the example value is capitalized and that there's a note about it.

Copy link

@m-sample m-sample left a comment

Choose a reason for hiding this comment

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

LGTM

type: keyword
ignore_above: 1024
description: 'An array of digests of the image the container was built on. Each
digest consists of the hash algorithm and value in this format: `algorithm:value`.'

Choose a reason for hiding this comment

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

I would just add "Algorithm names in this value should align with the field names in the ECS hash field set" if that makes sense.

@daniel-almeida daniel-almeida changed the title Add orchestrator (resource.parent_type and resource.ip) and container (container.image.hash) fields Add orchestrator (resource.parent.type and resource.ip) and container (container.image.hash.all) fields May 2, 2022
Copy link
Member

@ebeahan ebeahan left a comment

Choose a reason for hiding this comment

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

LGTM

@daniel-almeida daniel-almeida changed the title Add orchestrator (resource.parent.type and resource.ip) and container (container.image.hash.all) fields Add orchestrator (resource.parent.type and resource.ip) and container (image.hash.all) fields May 2, 2022
@daniel-almeida daniel-almeida merged commit 3846878 into main May 2, 2022
ebeahan pushed a commit to ebeahan/ecs that referenced this pull request May 2, 2022
… (image.hash.all) fields (elastic#1889)

* Add orchestrator.resource parent_type and ip fields and container.image.hash field.

* Add generated artifacts.

* Update CHANGELOG.

* Update definition of container.image.hash

* Address PR comments.

* Address PR comments.

* Add container.image.hash.all

* address PR comment

* Update CHANGELOG.next

(cherry picked from commit 3846878)

# Conflicts:
#	experimental/generated/csv/fields.csv
#	generated/csv/fields.csv
@ebeahan
Copy link
Member

ebeahan commented May 2, 2022

💚 All backports created successfully

Status Branch Result
8.3

Questions ?

Please refer to the Backport tool documentation

ebeahan added a commit that referenced this pull request May 2, 2022
… (image.hash.all) fields (#1889) (#1896)

* Add orchestrator.resource parent_type and ip fields and container.image.hash field.

* Add generated artifacts.

* Update CHANGELOG.

* Update definition of container.image.hash

* Address PR comments.

* Address PR comments.

* Add container.image.hash.all

* address PR comment

* Update CHANGELOG.next

(cherry picked from commit 3846878)

Co-authored-by: Daniel Araujo Almeida <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants