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 unit test to not log stdout or stderr fields on create task request #782

Conversation

austinvazquez
Copy link
Contributor

@austinvazquez austinvazquez commented Feb 17, 2024

Issue #, if available:
Validates #781

Description of changes:
This change adds a unit test to validate when launching a container with the firecracker runtime the shim implementation will not log the stdout/stderr shim logger binary URI to disk.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@austinvazquez austinvazquez force-pushed the add-integration-test-for-stdout-stderr branch 2 times, most recently from db20dea to 8ec2104 Compare February 21, 2024 16:52
@austinvazquez austinvazquez changed the title Add integration test for stdout stderr Add unit test to not log stdout or stderr fields on create task request Feb 21, 2024
@austinvazquez austinvazquez marked this pull request as ready for review February 21, 2024 16:54
@austinvazquez austinvazquez requested a review from a team as a code owner February 21, 2024 16:54
Copy link

@sondavidb sondavidb left a comment

Choose a reason for hiding this comment

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

Is there a mechanism for not redacting the info? (e.g. if a debug flag is set) If so, we might want to make sure that it gets tested as well.

testLogger.Level = logrus.DebugLevel

vmIsReady := make(chan struct{})
close(vmIsReady)

Choose a reason for hiding this comment

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

defer close(vmisReady)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, the channel is closed after the CreateVM API call is made. So mocking here the VM is ready.

@austinvazquez
Copy link
Contributor Author

Is there a mechanism for not redacting the info? (e.g. if a debug flag is set) If so, we might want to make sure that it gets tested as well.

Not that I have found, but open to ideas there.

@austinvazquez austinvazquez force-pushed the add-integration-test-for-stdout-stderr branch from 8ec2104 to cb3b0a8 Compare February 21, 2024 18:41
// (*service).Create will fail on (Dir).CreateBundleLink after the log we want to validate.
_, _ = uut.Create(ctx, createTaskRequest)

for _, entry := range hook.AllEntries() {
Copy link
Contributor

Choose a reason for hiding this comment

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

For sanity, can you assert that your configured logger is actually logging? Like, check that it logs the task ID.

Copy link
Contributor Author

@austinvazquez austinvazquez Feb 21, 2024

Choose a reason for hiding this comment

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

Good call, added lines 355 and 358 for this.

@austinvazquez austinvazquez force-pushed the add-integration-test-for-stdout-stderr branch from cb3b0a8 to 5f9ef42 Compare February 21, 2024 22:03
In the shim logger use case, the stdout or stderr fields for create task
can be the full binary URI and contain sensitive information via
environment variables or parameters. Since this is not a clean solution
to redact this information, it is best to not log them to disk.

Signed-off-by: Austin Vazquez <[email protected]>
@austinvazquez austinvazquez force-pushed the add-integration-test-for-stdout-stderr branch from 5f9ef42 to 135e85a Compare February 21, 2024 22:08
@austinvazquez austinvazquez merged commit 6b2d232 into firecracker-microvm:main Feb 21, 2024
10 checks passed
@austinvazquez austinvazquez deleted the add-integration-test-for-stdout-stderr branch February 21, 2024 22:26
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