Skip to content

Commit 3bb5a99

Browse files
committed
fix codeql concerns
1 parent c685c85 commit 3bb5a99

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

agent-launcher/src/main/java/io/sentrius/agent/launcher/api/AgentLauncherController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public ResponseEntity<String> getAgentStatus(@RequestParam(name="agentId") Strin
6969
try {
7070
return ResponseEntity.ok(podLauncherService.statusById(agentId) );
7171
} catch (Exception e) {
72-
return ResponseEntity.status(500).body("Status failed: " + e.getMessage());
72+
log.error("Status failed", e);
73+
return ResponseEntity.status(500).body("Status retrieval failed");
7374
}
7475
}
7576

api/src/main/java/io/sentrius/sso/controllers/api/AgentBootstrapController.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,6 @@ public ResponseEntity<String> getAgentStatus(
221221
@RequestParam("agentId") String agentId, HttpServletRequest request, HttpServletResponse response
222222
) throws GeneralSecurityException, IOException, ZtatException {
223223

224-
225-
var operatingUser = getOperatingUser(request, response );
226224
String podResponse =
227225
agentClientService.getAgentPodStatus(appConfig.getSentriusLauncherService(), agentId);
228226
// bootstrap with a default policy

api/src/main/resources/templates/sso/agents/design_chat.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ <h2><i class="fas fa-robot"></i> Agent Designer</h2>
343343

344344
<script type="module">
345345
import * as Chat from '/js/chat.js';
346-
let sessionId = Math.floor(Math.random() * 1e12); // up to 12 digit
346+
let sessionId = crypto.randomUUID();
347347
let conversationHistory = [];
348348
let availableAgent = null;
349349
const csrfToken = document.getElementById("csrf-token").value;
@@ -611,7 +611,7 @@ <h2><i class="fas fa-robot"></i> Agent Designer</h2>
611611
</div>
612612
`;
613613
conversationHistory = [];
614-
sessionId = Math.floor(Math.random() * 1e12); // up to 12 digit
614+
sessionId = crypto.randomUUID();
615615
}
616616

617617
window.clearChat = clearChat;

api/src/main/resources/templates/sso/atpl/chat.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ <h2><i class="fas fa-robot"></i> ATPL Configuration Assistant</h2>
361361

362362
<script type="module">
363363
import * as Chat from '/js/chat.js';
364-
let sessionId = Math.floor(Math.random() * 1e12); // up to 12 digit
364+
let sessionId = crypto.randomUUID();
365365
let conversationHistory = [];
366366
let availableAgent = null;
367367
const csrfToken = document.getElementById("csrf-token").value;
@@ -588,7 +588,7 @@ <h2><i class="fas fa-robot"></i> ATPL Configuration Assistant</h2>
588588
</div>
589589
`;
590590
conversationHistory = [];
591-
sessionId = Math.floor(Math.random() * 1e12); // up to 12 digit
591+
sessionId = crypto.randomUUID();
592592
}
593593

594594
window.clearChat = clearChat;

core/src/main/java/io/sentrius/sso/core/services/agents/AgentClientService.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,31 @@ public List<EndpointDescriptor> getAvailableVerbs(TokenDTO token) throws ZtatExc
240240
}
241241

242242
public String getAgentPodStatus(String launcherService, String agentId) throws ZtatException {
243-
return zeroTrustClientService.callAuthenticatedGetOnApi(launcherService,
243+
var podResponse = zeroTrustClientService.callAuthenticatedGetOnApi(launcherService,
244244
"agent/launcher" +
245245
"/status", Maps.immutableEntry("agentId", List.of(agentId)) );
246+
String apiResponse = "Running";
247+
switch(podResponse){
248+
case "Running":
249+
apiResponse = "Running";
250+
break;
251+
case "Pending":
252+
apiResponse = "Pending";
253+
break;
254+
case "Succeeded":
255+
apiResponse = "Succeeded";
256+
break;
257+
case "Failed":
258+
apiResponse = "Failed";
259+
break;
260+
case "NotFound":
261+
apiResponse = "NotFound";
262+
break;
263+
default:
264+
log.error("Unknown pod status response: {}", podResponse);
265+
apiResponse = "Unknown";
266+
}
267+
return apiResponse;
246268
}
247269

248270
public AgentContextDTO getAgentContext(TokenDTO token, String agentContextId) throws ZtatException,

0 commit comments

Comments
 (0)