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

Feature/remove unirest #1

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open

Feature/remove unirest #1

wants to merge 47 commits into from

Conversation

mehab
Copy link
Owner

@mehab mehab commented Jan 23, 2023

Description

Addressed Issue

Additional Details

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

.intervalFunction(ofExponentialBackoff(
Duration.ofSeconds(Config.getInstance().getPropertyAsInt(ConfigKey.SNYK_RETRY_EXPONENTIAL_BACKOFF_INITIAL_DURATION_SECONDS)),
Config.getInstance().getPropertyAsInt(ConfigKey.SNYK_RETRY_EXPONENTIAL_BACKOFF_MULTIPLIER),
Duration.ofSeconds(Config.getInstance().getPropertyAsInt(ConfigKey.SNYK_RETRY_EXPONENTIAL_BACKOFF_MAX_DURATION_SECONDS))
))
.maxAttempts(Config.getInstance().getPropertyAsInt(ConfigKey.SNYK_RETRY_MAX_ATTEMPTS))
.retryOnException(exception -> false)
.retryOnResult(response -> HttpStatus.TOO_MANY_REQUESTS == response.getStatus())
.retryOnResult(response -> 429 == response.getStatusLine().getStatusCode())
Copy link

Choose a reason for hiding this comment

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

5% of developers fix this issue

YodaCondition: The non-constant portion of an equals check generally comes first.


Suggested change
.retryOnResult(response -> 429 == response.getStatusLine().getStatusCode())
.retryOnResult(response -> response.getStatusLine().getStatusCode() == 429)

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
if (response.getEntity()!=null) {
String responseString = EntityUtils.toString(response.getEntity());
final JSONObject responseJson = new org.json.JSONObject(responseString);
Copy link

Choose a reason for hiding this comment

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

26% of developers fix this issue

UnnecessarilyFullyQualified: This fully qualified name is unambiguous to the compiler if imported.


Suggested change
final JSONObject responseJson = new org.json.JSONObject(responseString);
final JSONObject responseJson = new JSONObject(responseString);

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Results results;
try{
if (response != null) {
if (response.getStatusLine().getStatusCode() == org.apache.http.HttpStatus.SC_OK) {
Copy link

Choose a reason for hiding this comment

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

26% of developers fix this issue

UnnecessarilyFullyQualified: This fully qualified name is unambiguous to the compiler if imported.


Suggested change
if (response.getStatusLine().getStatusCode() == org.apache.http.HttpStatus.SC_OK) {
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

final HttpEntity entity = response.getEntity();
if (entity != null) {
try (InputStream in = entity.getContent()) {
final Document document = XmlUtil.buildSecureDocumentBuilder().parse(in);
Copy link

Choose a reason for hiding this comment

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

XXE_DOCUMENT: The use of DocumentBuilder.parse(...) (DocumentBuilder) is vulnerable to XML External Entity attacks


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@@ -66,21 +63,13 @@ public MetaModel analyze(final Component component) {
if (component.getPurl() == null || component.getPurl().getNamespace() == null) {
return meta;
}

final UnirestInstance ui = UnirestFactory.getUnirestInstance();
final String url = String.format(baseUrl + API_URL, caseEncode(component.getPurl().getNamespace()), caseEncode(component.getPurl().getName()));
Copy link

Choose a reason for hiding this comment

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

7% of developers fix this issue

💬 23 similar findings have been found in this PR


Var: Unnecessary 'final' modifier.


Suggested change
final String url = String.format(baseUrl + API_URL, caseEncode(component.getPurl().getNamespace()), caseEncode(component.getPurl().getName()));
String url = String.format(baseUrl + API_URL, caseEncode(component.getPurl().getNamespace()), caseEncode(component.getPurl().getName()));

🔎 Expand here to view all instances of this finding
File Path Line Number
src/main/java/org/dependencytrack/tasks/scanners/SnykAnalysisTask.java 328
src/main/java/org/dependencytrack/util/VulnDBUtil.java 201
src/main/java/org/dependencytrack/util/VulnDBUtil.java 165
src/main/java/org/dependencytrack/tasks/scanners/SnykAnalysisTask.java 106
src/main/java/org/dependencytrack/tasks/repositories/GemMetaAnalyzer.java 65
src/main/java/org/dependencytrack/util/VulnDBUtil.java 134
src/main/java/org/dependencytrack/tasks/scanners/SnykAnalysisTask.java 345
src/main/java/org/dependencytrack/util/VulnDBUtil.java 116
src/main/java/org/dependencytrack/tasks/repositories/GoModulesMetaAnalyzer.java 68
src/main/java/org/dependencytrack/tasks/repositories/GemMetaAnalyzer.java 69

Showing 10 of 23 findings. Visit the Lift Web Console to see all.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

if (extTexts != null) {
for(int j = 0; j < extTexts.length(); ++j) {
JSONObject jso = extTexts.getJSONObject(j);
ExternalText externalText = new ExternalText();
Copy link

Choose a reason for hiding this comment

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

19% of developers fix this issue

💬 20 similar findings have been found in this PR


Varifier: Consider using var here to avoid boilerplate.


Suggested change
ExternalText externalText = new ExternalText();
var externalText = new ExternalText();

🔎 Expand here to view all instances of this finding
File Path Line Number
src/main/java/org/dependencytrack/tasks/scanners/SnykAnalysisTask.java 327
src/main/java/org/dependencytrack/util/VulnDBUtil.java 190
src/main/java/org/dependencytrack/util/VulnDBUtil.java 81
src/main/java/org/dependencytrack/tasks/repositories/GemMetaAnalyzer.java 73
src/main/java/org/dependencytrack/util/VulnDBUtil.java 278
src/main/java/org/dependencytrack/util/VulnDBUtil.java 322
src/main/java/org/dependencytrack/tasks/repositories/GoModulesMetaAnalyzer.java 72
src/main/java/org/dependencytrack/util/VulnDBUtil.java 171
src/main/java/org/dependencytrack/util/VulnDBUtil.java 155
src/main/java/org/dependencytrack/tasks/scanners/SnykAnalysisTask.java 106

Showing 10 of 20 findings. Visit the Lift Web Console to see all.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@@ -64,29 +63,24 @@ public RepositoryType supportedRepositoryType() {
* {@inheritDoc}
*/
public MetaModel analyze(final Component component) {
Copy link

Choose a reason for hiding this comment

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

6% of developers fix this issue

💬 17 similar findings have been found in this PR


UnnecessaryFinal: Since Java 8, it's been unnecessary to make local variables and parameters final for use in lambdas or anonymous classes. Marking them as final is weakly discouraged, as it adds a fair amount of noise for minimal benefit.


Suggested change
public MetaModel analyze(final Component component) {
public MetaModel analyze( Component component) {

🔎 Expand here to view all instances of this finding
File Path Line Number
src/main/java/org/dependencytrack/tasks/scanners/SnykAnalysisTask.java 298
src/main/java/org/dependencytrack/tasks/scanners/SnykAnalysisTask.java 300
src/main/java/org/dependencytrack/tasks/scanners/SnykAnalysisTask.java 106
src/main/java/org/dependencytrack/tasks/repositories/GoModulesMetaAnalyzer.java 68
src/main/java/org/dependencytrack/tasks/scanners/SnykAnalysisTask.java 299
src/main/java/org/dependencytrack/tasks/scanners/SnykAnalysisTask.java 306
src/main/java/org/dependencytrack/tasks/repositories/GemMetaAnalyzer.java 68
src/main/java/org/dependencytrack/tasks/scanners/SnykAnalysisTask.java 328
src/main/java/org/dependencytrack/tasks/repositories/GoModulesMetaAnalyzer.java 72
src/main/java/org/dependencytrack/tasks/repositories/AbstractMetaAnalyzer.java 95

Showing 10 of 17 findings. Visit the Lift Web Console to see all.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

.formatted(component.getPurl(), response.getStatus(), errors.stream()
.map(error -> " - %s: %s (%s)".formatted(error.title(), error.detail(), error.code()))
.collect(Collectors.joining("\n"))));
final HttpUriRequest request = new HttpGet(requestUrl);
Copy link

Choose a reason for hiding this comment

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

5% of developers fix this issue

💬 4 similar findings have been found in this PR


HTTP_PARAMETER_POLLUTION: Concatenating user-controlled input into a URL


🔎 Expand here to view all instances of this finding
File Path Line Number
src/main/java/org/dependencytrack/integrations/defectdojo/DefectDojoClient.java 100
src/main/java/org/dependencytrack/integrations/defectdojo/DefectDojoClient.java 115
src/main/java/org/dependencytrack/tasks/repositories/AbstractMetaAnalyzer.java 95
src/main/java/org/dependencytrack/util/VulnDBUtil.java 81

Visit the Lift Web Console to find more details in your report.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@sonatype-lift
Copy link

sonatype-lift bot commented Jan 23, 2023

🛠 Lift Auto-fix

Some of the Lift findings in this PR can be automatically fixed. You can download and apply these changes in your local project directory of your branch to review the suggestions before committing.1

# Download the patch
curl https://lift.sonatype.com/api/patch/github.com/mehab/dependency-track/1.diff -o lift-autofixes.diff

# Apply the patch with git
git apply lift-autofixes.diff

# Review the changes
git diff

Want it all in a single command? Open a terminal in your project's directory and copy and paste the following command:

curl https://lift.sonatype.com/api/patch/github.com/mehab/dependency-track/1.diff | git apply

Once you're satisfied commit and push your changes in your project.

Footnotes

  1. You can preview the patch by opening the patch URL in the browser.

logger.error("Destination: " + destination);
logger.error("Response: " + response.getBody());
logger.debug(content);
HttpPost request = new HttpPost(destination);
Copy link

Choose a reason for hiding this comment

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

14% of developers fix this issue

Varifier: Consider using var here to avoid boilerplate.


Suggested change
HttpPost request = new HttpPost(destination);
var request = new HttpPost(destination);

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@@ -46,33 +54,31 @@ public void publish(final String publisherName, final PebbleTemplate template, f
return;
}
final String mimeType = getTemplateMimeType(config);
Copy link

Choose a reason for hiding this comment

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

7% of developers fix this issue

💬 10 similar findings have been found in this PR


Var: Unnecessary 'final' modifier.


Suggested change
final String mimeType = getTemplateMimeType(config);
String mimeType = getTemplateMimeType(config);

🔎 Expand here to view all instances of this finding
File Path Line Number
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 61
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 96
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 44
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 43
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 43
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 43
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 85
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 43
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 72
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 96

Visit the Lift Web Console to find more details in your report.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]


public abstract class AbstractWebhookPublisher implements Publisher {
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(AbstractWebhookPublisher.class);

public void publish(final String publisherName, final PebbleTemplate template, final Notification notification, final JsonObject config) {
Copy link

Choose a reason for hiding this comment

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

5% of developers fix this issue

💬 10 similar findings have been found in this PR


UnnecessaryFinal: Since Java 8, it's been unnecessary to make local variables and parameters final for use in lambdas or anonymous classes. Marking them as final is weakly discouraged, as it adds a fair amount of noise for minimal benefit.


Suggested change
public void publish(final String publisherName, final PebbleTemplate template, final Notification notification, final JsonObject config) {
public void publish(final String publisherName, final PebbleTemplate template, Notification notification, final JsonObject config) {

🔎 Expand here to view all instances of this finding
File Path Line Number
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 44
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 43
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 43
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 43
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 96
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 96
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 72
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 56
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 85
src/main/java/org/dependencytrack/notification/publisher/AbstractWebhookPublisher.java 61

Visit the Lift Web Console to find more details in your report.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

HttpPost request = new HttpPost(builder.build());
request.addHeader("accept", "application/xml");
HttpEntity data = MultipartEntityBuilder.create().setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
.addBinaryBody("files[]", findingsJson, org.apache.http.entity.ContentType.APPLICATION_JSON, "findings.json")
Copy link

Choose a reason for hiding this comment

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

23% of developers fix this issue

UnnecessarilyFullyQualified: This fully qualified name is unambiguous to the compiler if imported.


Suggested change
.addBinaryBody("files[]", findingsJson, org.apache.http.entity.ContentType.APPLICATION_JSON, "findings.json")
.addBinaryBody("files[]", findingsJson, ContentType.APPLICATION_JSON, "findings.json")

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

final JSONObject crate = response.getBody().getObject().optJSONObject("crate");
try (final CloseableHttpResponse response = processHttpRequest(url)) {
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
final HttpEntity entity = response.getEntity();
Copy link

Choose a reason for hiding this comment

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

11% of developers fix this issue

💬 15 similar findings have been found in this PR


Var: Unnecessary 'final' modifier.


Suggested change
final HttpEntity entity = response.getEntity();
HttpEntity entity = response.getEntity();

🔎 Expand here to view all instances of this finding
File Path Line Number
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 72
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 70
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 88
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 90
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 87
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 81
src/main/java/org/dependencytrack/integrations/fortifyssc/FortifySscClient.java 79
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 69
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 84
src/main/java/org/dependencytrack/integrations/fortifyssc/FortifySscClient.java 54

Showing 10 of 15 findings. Visit the Lift Web Console to see all.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

final JSONObject crate = response.getBody().getObject().optJSONObject("crate");
try (final CloseableHttpResponse response = processHttpRequest(url)) {
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
final HttpEntity entity = response.getEntity();
Copy link

Choose a reason for hiding this comment

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

10% of developers fix this issue

💬 15 similar findings have been found in this PR


UnnecessaryFinal: Since Java 8, it's been unnecessary to make local variables and parameters final for use in lambdas or anonymous classes. Marking them as final is weakly discouraged, as it adds a fair amount of noise for minimal benefit.


Suggested change
final HttpEntity entity = response.getEntity();
HttpEntity entity = response.getEntity();

🔎 Expand here to view all instances of this finding
File Path Line Number
src/main/java/org/dependencytrack/integrations/fortifyssc/FortifySscClient.java 54
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 73
src/main/java/org/dependencytrack/integrations/fortifyssc/FortifySscClient.java 79
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 79
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 88
src/main/java/org/dependencytrack/integrations/fortifyssc/FortifySscClient.java 51
src/main/java/org/dependencytrack/integrations/fortifyssc/FortifySscClient.java 79
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 81
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 72
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 90

Showing 10 of 15 findings. Visit the Lift Web Console to see all.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@@ -45,49 +50,54 @@ public FortifySscClient(final FortifySscUploader uploader, final URL baseURL) {

public String generateOneTimeUploadToken(final String citoken) {
LOGGER.debug("Generating one-time upload token");
final UnirestInstance ui = UnirestFactory.getUnirestInstance();
HttpPost request = new HttpPost(baseURL + "/api/v1/fileTokens");
Copy link

Choose a reason for hiding this comment

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

14% of developers fix this issue

💬 3 similar findings have been found in this PR


Varifier: Consider using var here to avoid boilerplate.


Suggested change
HttpPost request = new HttpPost(baseURL + "/api/v1/fileTokens");
var request = new HttpPost(baseURL + "/api/v1/fileTokens");

🔎 Expand here to view all instances of this finding
File Path Line Number
src/main/java/org/dependencytrack/integrations/fortifyssc/FortifySscClient.java 63
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 78
src/main/java/org/dependencytrack/tasks/repositories/CargoMetaAnalyzer.java 70

Visit the Lift Web Console to find more details in your report.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

}

public <T> Results<T> parse(File file, Class<? extends ApiObject> apiObject) throws IOException {
String jsonData = Files.readString(Paths.get(file.toURI()), Charset.defaultCharset());
Copy link

Choose a reason for hiding this comment

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

8% of developers fix this issue

PATH_TRAVERSAL_IN: This API (java/nio/file/Paths.get(Ljava/net/URI;)Ljava/nio/file/Path;) reads a file whose location might be specified by user input


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@@ -663,8 +665,11 @@ public static org.cyclonedx.model.vulnerability.Vulnerability convert(final Quer
}

/**
* Converts a parsed Bom to a native list of Dependency-Track component object
* Converts a parsed Bom to a native list of Dependency-Track component objects
* @param qm
Copy link

Choose a reason for hiding this comment

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

18% of developers fix this issue

EmptyBlockTag: A block tag (@param, @return, @throws, @deprecated) has an empty description. Block tags without descriptions don't add much value for future readers of the code; consider removing the tag entirely or adding a description.


Suggested change
* @param qm
*

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

final JSONArray jsonArray = new JSONArray();
final org.cyclonedx.model.Dependency d1 = getDependencyFromBomRef(c1.getBomRef(), bom.getDependencies());
final org.cyclonedx.model.Dependency d1 = getDependencyFromBomRef(c1.getKey(), bom.getDependencies());
Copy link

Choose a reason for hiding this comment

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

13% of developers fix this issue

UnnecessarilyFullyQualified: This fully qualified name is unambiguous to the compiler if imported.


Suggested change
final org.cyclonedx.model.Dependency d1 = getDependencyFromBomRef(c1.getKey(), bom.getDependencies());
final Dependency targetDep = getDependencyFromBomRef(targetBomRef, bom.getDependencies());

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

}

public <T> Results<T> parse(File file, Class<? extends ApiObject> apiObject) throws IOException {
String jsonData = Files.readString(Paths.get(file.toURI()), Charset.defaultCharset());
Copy link

Choose a reason for hiding this comment

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

8% of developers fix this issue

PATH_TRAVERSAL_IN: This API (java/nio/file/Paths.get(Ljava/net/URI;)Ljava/nio/file/Path;) reads a file whose location might be specified by user input


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

}

public <T> Results<T> parse(File file, Class<? extends ApiObject> apiObject) throws IOException {
String jsonData = Files.readString(Paths.get(file.toURI()), Charset.defaultCharset());
Copy link

Choose a reason for hiding this comment

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

8% of developers fix this issue

PATH_TRAVERSAL_IN: This API (java/nio/file/Paths.get(Ljava/net/URI;)Ljava/nio/file/Path;) reads a file whose location might be specified by user input


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]


final LocalDate publishedDate = LocalDate.ofInstant(published.toInstant(), ZoneId.systemDefault());
final LocalDate ageDate = publishedDate.plus(agePeriod);
final LocalDate today = LocalDate.now();
Copy link

Choose a reason for hiding this comment

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

63% of developers fix this issue

JavaTimeDefaultTimeZone: LocalDate.now() is not allowed because it silently uses the system default time-zone. You must pass an explicit time-zone (e.g., ZoneId.of("America/Los_Angeles")) to this method.


Suggested change
final LocalDate today = LocalDate.now();
final LocalDate today = LocalDate.now(ZoneId.systemDefault());

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

case NUMERIC_EQUAL -> ageDate.isEqual(today);
case NUMERIC_NOT_EQUAL -> !ageDate.isEqual(today);
case NUMERIC_LESSER_THAN_OR_EQUAL -> ageDate.isEqual(today) || ageDate.isAfter(today);
case NUMERIC_LESS_THAN -> ageDate.isAfter(LocalDate.now());
Copy link

Choose a reason for hiding this comment

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

63% of developers fix this issue

JavaTimeDefaultTimeZone: LocalDate.now() is not allowed because it silently uses the system default time-zone. You must pass an explicit time-zone (e.g., ZoneId.of("America/Los_Angeles")) to this method.


Suggested change
case NUMERIC_LESS_THAN -> ageDate.isAfter(LocalDate.now());
case NUMERIC_LESS_THAN -> ageDate.isAfter(LocalDate.now(ZoneId.systemDefault()));

ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@@ -55,6 +55,7 @@ public PolicyEngine() {
evaluators.add(new CpePolicyEvaluator());
evaluators.add(new SwidTagIdPolicyEvaluator());
evaluators.add(new VersionPolicyEvaluator());
evaluators.add(new ComponentAgePolicyEvaluator());
Copy link

Choose a reason for hiding this comment

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

8% of developers fix this issue

RESOURCE_LEAK: resource of type org.dependencytrack.persistence.QueryManager acquired by call to ComponentAgePolicyEvaluator() at line 58 is not released after line 58.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

.addPart("close_old_findings", new StringBody("true", ContentType.MULTIPART_FORM_DATA))
.addPart("push_to_jira", new StringBody("push_to_jira", ContentType.MULTIPART_FORM_DATA))
.addPart("test", new StringBody(testId, ContentType.MULTIPART_FORM_DATA))
.addPart("scan_date", new StringBody(DATE_FORMAT.format(new Date()), ContentType.MULTIPART_FORM_DATA))
Copy link

Choose a reason for hiding this comment

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

24% of developers fix this issue

JavaUtilDate: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

.addPart("minimum_severity", new StringBody("Info", ContentType.MULTIPART_FORM_DATA))
.addPart("close_old_findings", new StringBody("true", ContentType.MULTIPART_FORM_DATA))
.addPart("push_to_jira", new StringBody("push_to_jira", ContentType.MULTIPART_FORM_DATA))
.addPart("scan_date", new StringBody(DATE_FORMAT.format(new Date()), ContentType.MULTIPART_FORM_DATA))
Copy link

Choose a reason for hiding this comment

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

24% of developers fix this issue

JavaUtilDate: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

}

public <T> Results<T> parse(File file, Class<? extends ApiObject> apiObject) throws IOException {
String jsonData = Files.readString(Paths.get(file.toURI()), Charset.defaultCharset());
Copy link

Choose a reason for hiding this comment

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

7% of developers fix this issue

PATH_TRAVERSAL_IN: This API (java/nio/file/Paths.get(Ljava/net/URI;)Ljava/nio/file/Path;) reads a file whose location might be specified by user input


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@@ -147,7 +147,7 @@ protected void handleUnexpectedHttpResponse(final Logger logger, String url, fin
);
}

protected void handleRequestException(final Logger logger, final Exception e) {
protected void handleRequestException(final Logger logger, final Throwable e) {
Copy link

Choose a reason for hiding this comment

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

79% of developers fix this issue

InconsistentCapitalization: Found the field 'LOGGER' with the same name as the parameter 'logger' but with different capitalization.


Suggested change
protected void handleRequestException(final Logger logger, final Throwable e) {
protected void handleRequestException(final Logger LOGGER, final Throwable e) {

ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

mehab pushed a commit that referenced this pull request Jun 27, 2023
Update from dependency-track
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.

1 participant