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

[Dynamic Security Analysis] Add endpoints for managing parameters and running computation #665

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

thangqp
Copy link
Contributor

@thangqp thangqp commented Jan 13, 2025

No description provided.

thangqp and others added 4 commits February 6, 2025 17:19
String endPointUrl = buildEndPointUrl(getBaseUri(), DYNAMIC_SECURITY_ANALYSIS_API_VERSION, DYNAMIC_SECURITY_ANALYSIS_END_POINT_PARAMETER);

String url = UriComponentsBuilder
.fromHttpUrl(endPointUrl + "{uuid}")
Copy link

@basseche basseche Feb 7, 2025

Choose a reason for hiding this comment

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

this literal is used 3 times in the code. Define a constant instead.

}

public void updateProvider(UUID parametersUuid, String provider) {
Objects.requireNonNull(parametersUuid);
Copy link

@basseche basseche Feb 7, 2025

Choose a reason for hiding this comment

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

you can use NonNull annotation instead of this kind of check :

public void updateProvider(@NonNull UUID parametersUuid, @NonNull String provider) { ...}

}

public UUID createParameters(String parametersInfos) {
Objects.requireNonNull(parametersInfos);
Copy link

Choose a reason for hiding this comment

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

NonNull annotation ?

Objects.requireNonNull(parametersUuid);
Objects.requireNonNull(provider);

String endPointUrl = buildEndPointUrl(getBaseUri(), DYNAMIC_SECURITY_ANALYSIS_API_VERSION, DYNAMIC_SECURITY_ANALYSIS_END_POINT_PARAMETER);
Copy link

@basseche basseche Feb 7, 2025

Choose a reason for hiding this comment

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

this function is called in almost every function, maybe put it in class member attribute :
endpointUrl for example or class member function to avoid code duplication.

}

public DynamicSecurityAnalysisStatus getStatus(UUID resultUuid) {
if (resultUuid == null) {
Copy link

Choose a reason for hiding this comment

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

Maybe simplify :
return resultUuid == null ? null : dynamicSecurityAnalysisClient.getStatus(resultUuid);

return dynamicSecurityAnalysisClient.getResultsCount();
}

public void assertDynamicSecurityAnalysisNotRunning(UUID resultUuid) {
Copy link

Choose a reason for hiding this comment

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

this function is not used !

public void invalidateStatus(List<UUID> resultUuids) {

if (resultUuids.isEmpty()) {
return;
Copy link

Choose a reason for hiding this comment

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

why don't you check for not empty and in this case call the rest of the code ?

Copy link

sonarqubecloud bot commented Feb 7, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
43.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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.

2 participants