Skip to content

[Fleet] Ensure top-level package vars are parsed when reading archive#147040

Merged
kpollich merged 1 commit intoelastic:mainfrom
kpollich:147028-missing-top-level-vars
Dec 5, 2022
Merged

[Fleet] Ensure top-level package vars are parsed when reading archive#147040
kpollich merged 1 commit intoelastic:mainfrom
kpollich:147028-missing-top-level-vars

Conversation

@kpollich
Copy link
Member

@kpollich kpollich commented Dec 5, 2022

Summary

Closes #147028

Testing instructions

See steps to reproduce in linked issue. Verify AWS credential variables appear on this branch.

image

I took a pass at adding tests for our parseAndVeryArchive method but it's sort of a recursive chain of mocked Buffer -> yaml.safeLoad operations and got pretty involved to set up from scratch. The other option would be to add an FTR API test that catches this case, but we'd need a package with top-level variables loaded into the test registry, which we may not have readily available if #146809 lands.

I would love some alternative ideas on adding test coverage for this fix, but if it's going to involved I don't want to block this fix from landing in 8.6 on tests.

@kpollich kpollich added release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team backport:prev-minor labels Dec 5, 2022
@kpollich kpollich self-assigned this Dec 5, 2022
@kpollich kpollich requested a review from a team as a code owner December 5, 2022 18:57
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@kpollich kpollich changed the title Ensure top-level package vars are parsed when reading archive [Fleet] Ensure top-level package vars are parsed when reading archive Dec 5, 2022
Copy link
Contributor

@jen-huang jen-huang left a comment

Choose a reason for hiding this comment

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

LGTM to unblock this important 8.6 fix.

Might we already have an issue filed to add tests for parseAndVerifyArchive?

@kibana-ci
Copy link

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 59 65 +6
osquery 109 115 +6
securitySolution 443 449 +6
total +20

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 68 74 +6
osquery 110 117 +7
securitySolution 520 526 +6
total +21

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @kpollich

@kpollich
Copy link
Member Author

kpollich commented Dec 5, 2022

Might we already have an issue filed to add tests for parseAndVerifyArchive?

I didn't find one, so I created #147050

@kpollich kpollich merged commit b6696ef into elastic:main Dec 5, 2022
@kpollich kpollich deleted the 147028-missing-top-level-vars branch December 5, 2022 20:13
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 5, 2022
…elastic#147040)

## Summary

Closes elastic#147028

## Testing instructions

See steps to reproduce in linked issue. Verify AWS credential variables
appear on this branch.

![image](https://user-images.githubusercontent.com/6766512/205719634-98bc4db8-25c4-4362-afba-5246fb5fb326.png)

I took a pass at adding tests for our `parseAndVeryArchive` method but
it's sort of a recursive chain of mocked `Buffer` -> `yaml.safeLoad`
operations and got pretty involved to set up from scratch. The other
option would be to add an FTR API test that catches this case, but we'd
need a package with top-level variables loaded into the test registry,
which we may not have readily available if
elastic#146809 lands.

I would love some alternative ideas on adding test coverage for this
fix, but if it's going to involved I don't want to block this fix from
landing in 8.6 on tests.

(cherry picked from commit b6696ef)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.6

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Dec 5, 2022
…rchive (#147040) (#147051)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[Fleet] Ensure top-level package vars are parsed when reading archive
(#147040)](#147040)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Kyle
Pollich","email":"kyle.pollich@elastic.co"},"sourceCommit":{"committedDate":"2022-12-05T20:13:19Z","message":"[Fleet]
Ensure top-level package vars are parsed when reading archive
(#147040)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/147028\r\n\r\n## Testing
instructions\r\n\r\nSee steps to reproduce in linked issue. Verify AWS
credential variables\r\nappear on this
branch.\r\n\r\n\r\n![image](https://user-images.githubusercontent.com/6766512/205719634-98bc4db8-25c4-4362-afba-5246fb5fb326.png)\r\n\r\nI
took a pass at adding tests for our `parseAndVeryArchive` method
but\r\nit's sort of a recursive chain of mocked `Buffer` ->
`yaml.safeLoad`\r\noperations and got pretty involved to set up from
scratch. The other\r\noption would be to add an FTR API test that
catches this case, but we'd\r\nneed a package with top-level variables
loaded into the test registry,\r\nwhich we may not have readily
available if\r\nhttps://github.com//pull/146809
lands.\r\n\r\nI would love some alternative ideas on adding test
coverage for this\r\nfix, but if it's going to involved I don't want to
block this fix from\r\nlanding in 8.6 on
tests.","sha":"b6696ef6c7da83c0ef396d24f471cb6589e5413a","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:prev-minor","v8.7.0"],"number":147040,"url":"https://github.com/elastic/kibana/pull/147040","mergeCommit":{"message":"[Fleet]
Ensure top-level package vars are parsed when reading archive
(#147040)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/147028\r\n\r\n## Testing
instructions\r\n\r\nSee steps to reproduce in linked issue. Verify AWS
credential variables\r\nappear on this
branch.\r\n\r\n\r\n![image](https://user-images.githubusercontent.com/6766512/205719634-98bc4db8-25c4-4362-afba-5246fb5fb326.png)\r\n\r\nI
took a pass at adding tests for our `parseAndVeryArchive` method
but\r\nit's sort of a recursive chain of mocked `Buffer` ->
`yaml.safeLoad`\r\noperations and got pretty involved to set up from
scratch. The other\r\noption would be to add an FTR API test that
catches this case, but we'd\r\nneed a package with top-level variables
loaded into the test registry,\r\nwhich we may not have readily
available if\r\nhttps://github.com//pull/146809
lands.\r\n\r\nI would love some alternative ideas on adding test
coverage for this\r\nfix, but if it's going to involved I don't want to
block this fix from\r\nlanding in 8.6 on
tests.","sha":"b6696ef6c7da83c0ef396d24f471cb6589e5413a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/147040","number":147040,"mergeCommit":{"message":"[Fleet]
Ensure top-level package vars are parsed when reading archive
(#147040)\n\n## Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/147028\r\n\r\n## Testing
instructions\r\n\r\nSee steps to reproduce in linked issue. Verify AWS
credential variables\r\nappear on this
branch.\r\n\r\n\r\n![image](https://user-images.githubusercontent.com/6766512/205719634-98bc4db8-25c4-4362-afba-5246fb5fb326.png)\r\n\r\nI
took a pass at adding tests for our `parseAndVeryArchive` method
but\r\nit's sort of a recursive chain of mocked `Buffer` ->
`yaml.safeLoad`\r\noperations and got pretty involved to set up from
scratch. The other\r\noption would be to add an FTR API test that
catches this case, but we'd\r\nneed a package with top-level variables
loaded into the test registry,\r\nwhich we may not have readily
available if\r\nhttps://github.com//pull/146809
lands.\r\n\r\nI would love some alternative ideas on adding test
coverage for this\r\nfix, but if it's going to involved I don't want to
block this fix from\r\nlanding in 8.6 on
tests.","sha":"b6696ef6c7da83c0ef396d24f471cb6589e5413a"}}]}]
BACKPORT-->

Co-authored-by: Kyle Pollich <kyle.pollich@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.6.0 v8.7.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fleet] Providing ?full query parameter to package details API causes package level variables to not be included in response

5 participants