-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backend] Added Agent ID at the implant command level for third-party…
… executors (#2263)
- Loading branch information
1 parent
f69fcbd
commit 4d971d9
Showing
4 changed files
with
82 additions
and
107 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
openbas-api/src/main/java/io/openbas/executors/ExecutorHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.openbas.executors; | ||
|
||
import io.openbas.database.model.Endpoint.PLATFORM_TYPE; | ||
|
||
public class ExecutorHelper { | ||
|
||
public static final String WINDOWS_LOCATION_PATH = "$PWD.Path"; | ||
public static final String UNIX_LOCATION_PATH = "$(pwd)"; | ||
|
||
private ExecutorHelper() {} | ||
|
||
public static String replaceArgs( | ||
PLATFORM_TYPE platformType, String command, String injectId, String agentId) { | ||
if (platformType == null || command == null || injectId == null || agentId == null) { | ||
throw new IllegalArgumentException( | ||
"Platform type, command, injectId, and agentId must not be null."); | ||
} | ||
|
||
String location = | ||
switch (platformType) { | ||
case Windows -> WINDOWS_LOCATION_PATH; | ||
case Linux, MacOS -> UNIX_LOCATION_PATH; | ||
default -> | ||
throw new IllegalArgumentException("Unsupported platform type: " + platformType); | ||
}; | ||
|
||
return command | ||
.replace("\"#{location}\"", location) | ||
.replace("#{inject}", injectId) | ||
.replace("#{agent}", agentId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters