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

chore: update package information report #2674

Merged
merged 16 commits into from
Apr 23, 2024
Merged

Conversation

JoeWang1127
Copy link
Collaborator

@JoeWang1127 JoeWang1127 commented Apr 19, 2024

In this PR:

  • Generate package information report for package that has no non-compliant licenses and security vulnerabilities.
  • Encode version using URLEncoder. The version may contain special characters that needs to be encoded before sending to deps.dev, e.g., 9+181-r4173-1.

An example of the report:

## Package information of io.opentelemetry:opentelemetry-api:1.37.0
Licenses: [Apache-2.0]
Vulnerabilities: None.
Checked in [deps.dev query](https://api.deps.dev/v3/query?versionKey.system=MAVEN&versionKey.name=io.opentelemetry:opentelemetry-api&versionKey.version=1.37.0)

## Dependencies:
## Package information of io.opentelemetry:opentelemetry-context:1.37.0
Licenses: [Apache-2.0]
Vulnerabilities: None.
Checked in [deps.dev query](https://api.deps.dev/v3/query?versionKey.system=MAVEN&versionKey.name=io.opentelemetry:opentelemetry-context&versionKey.version=1.37.0)

@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Apr 19, 2024
@JoeWang1127 JoeWang1127 added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 20, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 20, 2024
@JoeWang1127 JoeWang1127 added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 21, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 21, 2024
@JoeWang1127 JoeWang1127 marked this pull request as ready for review April 22, 2024 14:03
@JoeWang1127 JoeWang1127 requested a review from a team as a code owner April 22, 2024 14:03
@JoeWang1127 JoeWang1127 requested a review from suztomo April 22, 2024 14:04
@JoeWang1127
Copy link
Collaborator Author

"Downstream Unmanaged Dependency Check / validate (java-bigtable)" is irrelevant to this PR.

@JoeWang1127 JoeWang1127 added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 22, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 22, 2024
return builder.toString();
}

private void appendToReport(StringBuilder builder, PackageInfo packageInfo) {
Copy link
Member

Choose a reason for hiding this comment

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

static?

}

private String endSeparator() {
return "===========================================================";
}

private String packageInfoReport() {
Copy link
Member

Choose a reason for hiding this comment

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

Would you add a test case of the pull request description?

Java 17's test block should make it easy. https://blogs.oracle.com/javamagazine/post/text-blocks-come-to-java

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would you add a test case of the pull request description?

It's not easily test using unit test as the encoded string needs to be sent to deps.dev to verify the correctness.

I'll write an integration test for it.

Copy link
Member

Choose a reason for hiding this comment

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

Would you write this in a way that the formatter function should operate on a Record class to generate the formatted string.

In this design, the unit test for the formatter does not need to access deps.dev.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wrote unit tests to verify the encoded string.

builder.append(String.format("## Package information of %s\n", versionKey));
builder.append(String.format("Licenses: %s\n", packageInfo.licenses()));
builder.append(
String.format("Vulnerabilities: None.\nChecked in [deps.dev query](%s)\n",
Copy link
Member

Choose a reason for hiding this comment

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

The visible part of the link should have the artifact coordinates.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

builder.append("\n\n");
appendToReport(builder, packageInfos.get(0));

builder.append("## Dependencies:\n");
Copy link
Member

Choose a reason for hiding this comment

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

Having the headings of the same level line by line is strange. This means the 1st section is empty. Would you fix this somehow?

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@suztomo suztomo left a comment

Choose a reason for hiding this comment

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

Approving this, as it's good enhancement already. We may add more pull requests later to follow up.

}

private String endSeparator() {
return "===========================================================";
}

private String packageInfoReport() {
Copy link
Member

Choose a reason for hiding this comment

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

Would you write this in a way that the formatter function should operate on a Record class to generate the formatted string.

In this design, the unit test for the formatter does not need to access deps.dev.

@product-auto-label product-auto-label bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Apr 23, 2024
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: l Pull request size is large. labels Apr 23, 2024
@JoeWang1127 JoeWang1127 enabled auto-merge (squash) April 23, 2024 21:36
Copy link

Quality Gate Passed Quality Gate passed for 'gapic-generator-java-root'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

Quality Gate Passed Quality Gate passed for 'java_showcase_integration_tests'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@JoeWang1127 JoeWang1127 merged commit 463801c into main Apr 23, 2024
42 checks passed
@JoeWang1127 JoeWang1127 deleted the chore/update-report branch April 23, 2024 22:15
lqiu96 pushed a commit that referenced this pull request May 22, 2024
In this PR:
- Generate package information report for package that has no
non-compliant licenses and security vulnerabilities.
- Encode version using `URLEncoder`. The version may contain special
characters that needs to be encoded before sending to deps.dev, e.g.,
[9+181-r4173-1](https://deps.dev/maven/com.google.errorprone%3Ajavac-shaded/9%2B181-r4173-1).

An example of the report:
```
## Package information of io.opentelemetry:opentelemetry-api:1.37.0
Licenses: [Apache-2.0]
Vulnerabilities: None.
Checked in [deps.dev query](https://api.deps.dev/v3/query?versionKey.system=MAVEN&versionKey.name=io.opentelemetry:opentelemetry-api&versionKey.version=1.37.0)

## Dependencies:
## Package information of io.opentelemetry:opentelemetry-context:1.37.0
Licenses: [Apache-2.0]
Vulnerabilities: None.
Checked in [deps.dev query](https://api.deps.dev/v3/query?versionKey.system=MAVEN&versionKey.name=io.opentelemetry:opentelemetry-context&versionKey.version=1.37.0)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants