Skip to content

Commit

Permalink
Fix flagged SCA issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jultty committed Apr 2, 2024
1 parent e91a053 commit 0e6287c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/main/java/mirante/api/meta/MetaController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;


Expand All @@ -15,7 +15,7 @@ public static final class MetaData {

MetaData metadata = new MetaData();

@RequestMapping("/version")
@GetMapping("/version")
@ResponseBody
public MetaData version() {
return this.metadata;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mirante/api/security/SecUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class SecUtils {

public static Argon2PasswordEncoder encoder =
public static final Argon2PasswordEncoder encoder =
Argon2PasswordEncoder.defaultsForSpringSecurity_v5_8();

}
4 changes: 2 additions & 2 deletions src/test/java/mirante/api/security/AuthenticationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class AuthenticationTest {
class AuthenticationTest {

@Value("${server.port:8889}")
private String port;
Expand Down Expand Up @@ -100,4 +100,4 @@ void tokenEndpointReturnsOkWithAuthentication() {
authenticatedClient.get().uri("/auth/token/health").exchange()
.expectStatus().isOk();
}
}
}
21 changes: 7 additions & 14 deletions src/web/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,22 @@ exerciseSetDropdown.addEventListener('input', function () {

printCorrectOptions(selectedOptions, setOptions);
sendResponseEvent(selectedOptions);
sendResponseResult(selectedOptions);
sendResponseResult(selectedOptions, selectedSet);
});

}
});

function sendResponseResult(selection) {
function sendResponseResult(selection, set) {

const xhr = new XMLHttpRequest();
xhr.open('POST', 'http://localhost:8888/result');
xhr.setRequestHeader('Content-Type', 'application/json');

const result = {
time: new Date().getTime(),
set: {
id: exercise_set_id,
name: exercise_set_name,
access: exercise_set_access,
}
set: set.id,
selection: selection,
};

xhr.send(JSON.stringify(result));
Expand Down Expand Up @@ -88,7 +85,7 @@ function printCorrectOptions(selection, setOptions) {

selection.forEach(selectedOption => {
const option = setOptions.find(option => option.id === selectedOption);
if (option && option.correct) {
if (option?.correct) {
correctCount++;
} else {
incorrectCount++;
Expand Down Expand Up @@ -170,19 +167,15 @@ function populateExerciseContainer(exercises) {

function filterOptionsByExerciseSet(fullOptions, targetExerciseSetId) {
return fullOptions.filter(option => {
return (
option.exercise_id &&
option.exercise_id.set_id &&
option.exercise_id.set_id.id === targetExerciseSetId
);
return (option.exercise_id?.set_id?.id === targetExerciseSetId);
});
}

function extractExerciseSets(data) {
const uniqueExerciseSets = new Set();

data.forEach(option => {
if (option.exercise_id && option.exercise_id.set_id) {
if (option.exercise_id?.set_id) {
const setId = option.exercise_id.set_id.id;
const setName = option.exercise_id.set_id.name;

Expand Down

0 comments on commit 0e6287c

Please sign in to comment.