Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .local.env
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
SENTRIUS_VERSION=1.1.371
SENTRIUS_VERSION=1.1.375
SENTRIUS_SSH_VERSION=1.1.41
SENTRIUS_KEYCLOAK_VERSION=1.1.53
SENTRIUS_AGENT_VERSION=1.1.42
SENTRIUS_AI_AGENT_VERSION=1.1.264
LLMPROXY_VERSION=1.0.78
LAUNCHER_VERSION=1.0.82
AGENTPROXY_VERSION=1.0.85
SSHPROXY_VERSION=1.0.40
SSHPROXY_VERSION=1.0.87
4 changes: 2 additions & 2 deletions .local.env.bak
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
SENTRIUS_VERSION=1.1.371
SENTRIUS_VERSION=1.1.375
SENTRIUS_SSH_VERSION=1.1.41
SENTRIUS_KEYCLOAK_VERSION=1.1.53
SENTRIUS_AGENT_VERSION=1.1.42
SENTRIUS_AI_AGENT_VERSION=1.1.264
LLMPROXY_VERSION=1.0.78
LAUNCHER_VERSION=1.0.82
AGENTPROXY_VERSION=1.0.85
SSHPROXY_VERSION=1.0.40
SSHPROXY_VERSION=1.0.87
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ public String setOption(HttpServletRequest request, HttpServletResponse response
case "java.lang.Float":
results.add(systemOptions.setValue(option.getName(), Float.valueOf(entry.getValue()[0]), false));
break;
case "java.lang.Double":
results.add(systemOptions.setValue(option.getName(), Double.valueOf(entry.getValue()[0]), false));
break;
default:
log.error("Unsupported type: {}", option.getClosestType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,13 @@ public AuditOutput waitForOutput(Long time,
}

if (!persistentMessage.isEmpty()){
log.info("Persistent Message: {}", persistentMessage);
var trigger = persistentMessage.pop();
triggers.add( getTrigger(trigger));
}

if (!prompt.isEmpty()){
log.info("Prompt: {}", prompt);
var trigger = prompt.pop();
triggers.add( getTrigger(trigger));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public void sendToTerminalSession(String terminalSessionId, ConnectedSystem conn

public void processTerminalMessage(
ConnectedSystem terminalSessionId, Session.TerminalMessage terminalMessage) {
log.info("process terminal messsage");
if (!terminalSessionId.getSession().getClosed() && terminalMessage.getType() != Session.MessageType.HEARTBEAT) {

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public Optional<Trigger> trigger(String cmd) {
}

if (llmResponse.get() != null) {
log.info("OpenAI analysis completed. Malicious: {}, response: {}, question: {}", flaggedAsMalicious, llmResponse.get(), llmQuestion.get());
Trigger trg = llmQuestion.get() != null ? new Trigger(TriggerAction.PROMPT_ACTION, llmResponse.get(),
llmQuestion.get()) :
new Trigger(TriggerAction.PERSISTENT_MESSAGE, llmResponse.get());
Expand Down Expand Up @@ -183,6 +184,7 @@ public Optional<Trigger> onMessage(Session.TerminalMessage text) {
analysis.get();

if (llmResponse.get() != null && llmQuestion.get() != null) {
log.info("OpenAI analysis completed. Malicious: {}, response: {}, question: {}", flaggedAsMalicious, llmResponse.get(), llmQuestion.get());
Trigger trg = llmQuestion.get() != null && enableLLMQuestions ? new Trigger(TriggerAction.PROMPT_ACTION,
llmResponse.get(),
llmQuestion.get()) :
Expand All @@ -197,11 +199,14 @@ public Optional<Trigger> onMessage(Session.TerminalMessage text) {
}
}
if ((connectedSystem.getWebsocketListenerSessionId() == null || connectedSystem.getWebsocketListenerSessionId().isEmpty() ) && flaggedAsMalicious) {
log.info("Flagged as malicious but no websocket session ID available. Returning JIT action.");
if (llmQuestion.get()!= null){
log.info("Flagged as malicious but no websocket session ID available. Returning prompt action.");
Trigger trg = new Trigger(TriggerAction.PROMPT_ACTION, DESCRIPTION);
return Optional.of(trg);
}
else {
log.info("Flagged as malicious but no websocket session ID available. Returning JIT action.");
Trigger trg = new Trigger(TriggerAction.JIT_ACTION, DESCRIPTION);
return Optional.of(trg);
}
Expand Down
6 changes: 5 additions & 1 deletion ssh-proxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@
<artifactId>sentrius-dataplane</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>io.sentrius</groupId>
<artifactId>llm-dataplane</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<!-- Kubernetes client -->
<dependency>
<groupId>io.kubernetes</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package io.sentrius.sso.sshproxy.config;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import io.sentrius.sso.core.services.TerminalService;
import jakarta.annotation.PreDestroy;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
Expand All @@ -13,31 +16,37 @@
@Slf4j
@Configuration
@EnableAsync
@RequiredArgsConstructor
public class TaskConfig {

private final TerminalService terminalService;

// Keep a reference so we can shut it down explicitly on destroy, if desired.
private ThreadPoolTaskExecutor executor;

@Bean(name = "taskExecutor")
public Executor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(15);
executor.setMaxPoolSize(20);
executor.setQueueCapacity(100);
executor.setThreadNamePrefix("SentriusTask-");
executor.initialize();
return executor;
public ThreadPoolTaskExecutor taskExecutor() {
ThreadPoolTaskExecutor exec = new ThreadPoolTaskExecutor();
exec.setCorePoolSize(15);
exec.setMaxPoolSize(20);
exec.setQueueCapacity(100);
exec.setThreadNamePrefix("ProxySession-");
exec.setWaitForTasksToCompleteOnShutdown(true);
exec.setAwaitTerminationSeconds(30);
exec.initialize();

this.executor = exec; // assign the field, not a shadowed local
return exec; // expose as Executor for @Async
}

@PreDestroy
public void shutdownExecutor() {
if (executor != null) {
log.info("Shutting down task executor");
executor.shutdown();
}
log.info("Shutting down executor");
// Call shutdown on SshListenerService to close streams
// If you truly want this on application shutdown:
log.info("Shutting down TerminalService");
terminalService.shutdown();
}

@Autowired
private TerminalService terminalService;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class ResponseServiceSession implements DataSession {
private final InputStream in;
private final OutputStream out;
private final BaseAccessTokenAuditor auditor;
private String persistentMessage = "";
private ConnectedSystem connectedSystem;


Expand Down Expand Up @@ -83,7 +84,13 @@ public void sendMessage(WebSocketMessage<?> message) throws IOException {
break;

case PERSISTENT_MESSAGE:
msg = formatPersistentMessage(trigger, auditLog);
if (!persistentMessage.equals(trigger.getDescription())) {
log.info(ANSI_BOLD + "Persistent message: " + ANSI_RESET + trigger.getDescription());
msg = formatPersistentMessage(trigger, auditLog);
}
else {
log.info(ANSI_BOLD + "Persistent message: samesies" + ANSI_RESET);
}
break;
case APPROVE_ACTION:
msg = formatApproveMessage(trigger, auditLog);
Expand All @@ -106,6 +113,7 @@ public void sendMessage(WebSocketMessage<?> message) throws IOException {




}
}

Expand Down Expand Up @@ -163,11 +171,15 @@ private String formatRecordMessage(Session.Trigger trigger, Session.TerminalMess
}

private String formatPersistentMessage(Session.Trigger trigger, Session.TerminalMessage auditLog) {
if (trigger.getDescription() == null || trigger.getDescription().isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
sb.append("\r\n");
sb.append(ANSI_BLUE).append(ANSI_BOLD).append("💬 MESSAGE").append(ANSI_RESET).append("\r\n");
sb.append(ANSI_BLUE).append(ANSI_BOLD).append("💬 AI Monitor").append(ANSI_RESET).append("\r\n");
sb.append(ANSI_BLUE).append(trigger.getDescription()).append(ANSI_RESET).append("\r\n");
sb.append("\r\n");
persistentMessage = trigger.getDescription();
return sb.toString();
}

Expand Down
Loading