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 project name and group to bomupload logs #3690

Closed
wants to merge 5 commits into from

Conversation

2000rosser
Copy link
Contributor

@2000rosser 2000rosser commented May 10, 2024

Description

Currently there is no logs printed to display which group is creating the new project when uploading a bom using curl.

This change finds the group associated with the api-key and prints it in the logs along with the project name.

Addressed Issue

closes #3642

Checklist

  • I have read and understand the contributing guidelines
  • This PR fixes a defect, and I have provided tests to verify that the fix is effective
  • This PR implements an enhancement, and I have provided tests to verify that it works as intended
  • This PR introduces changes to the database model, and I have added corresponding update logic
  • This PR introduces new or alters existing behavior, and I have updated the documentation accordingly

Signed-off-by: Ross Murphy <RossMurphy@ibm.com>
Copy link

codacy-production bot commented May 10, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+1.09% (target: -1.00%) 0.00% (target: 70.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (fd82e58) 22052 16503 74.84%
Head commit (0610497) 22060 (+8) 16750 (+247) 75.93% (+1.09%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#3690) 2 0 0.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy will stop sending the deprecated coverage status from June 5th, 2024. Learn more

Signed-off-by: Ross Murphy <RossMurphy@ibm.com>
Signed-off-by: Ross Murphy <RossMurphy@ibm.com>
Signed-off-by: Ross Murphy <RossMurphy@ibm.com>
Signed-off-by: Ross Murphy <RossMurphy@ibm.com>
@valentijnscholten
Copy link
Contributor

I like this specific addition, but on a larger scale it might be better to setup a proper MDC so we can log the User or Team Principal for all log messages? (If the Alpine logging wrapper supports that or can be removed)

https://medium.com/javarevisited/mapped-diagnostic-context-mdc-6447b598736d

@nscuro
Copy link
Member

nscuro commented May 16, 2024

@valentijnscholten (If the Alpine logging wrapper supports that or can be removed)

It does, and I added the MDC context to the default logback config in v4.11. The new BOM processing task makes use of MDC already, and we're planning to adopt it in more areas:

final var ctx = new Context(event.getChainIdentifier(), event.getProject(), event.getBom());
try (var ignoredMdcProjectUuid = MDC.putCloseable(MDC_PROJECT_UUID, ctx.project.getUuid().toString());
var ignoredMdcProjectName = MDC.putCloseable(MDC_PROJECT_NAME, ctx.project.getName());
var ignoredMdcProjectVersion = MDC.putCloseable(MDC_PROJECT_VERSION, ctx.project.getVersion());
var ignoredMdcBomUploadToken = MDC.putCloseable(MDC_BOM_UPLOAD_TOKEN, ctx.token.toString())) {
processEvent(ctx, event);
}

For Alpine specifically, I recently added RequestIdFilter which adds a requestId field to the MDC.

We could do the same for AuthenticationFilter. That way, all logging statement past the authentication stage would include the principal's name automatically.

@2000rosser
Copy link
Contributor Author

2000rosser commented May 22, 2024

@nscuro I'd need to get permission to contribute to Alpine, so feel free to close this PR if thats the preferred approach

@nscuro nscuro closed this May 28, 2024
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.

Incomplete Recognition of Users/Projects Created through APIs.
3 participants