Skip to content
Open
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
2 changes: 1 addition & 1 deletion agent-manager/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
google.golang.org/grpc v1.81.1
google.golang.org/protobuf v1.36.11
gorm.io/driver/postgres v1.6.0
gorm.io/gorm v1.31.1
gorm.io/gorm v1.31.2
)

require go.mongodb.org/mongo-driver/v2 v2.6.0 // indirect
Expand Down
8 changes: 6 additions & 2 deletions agent-manager/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down Expand Up @@ -139,5 +141,7 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/postgres v1.6.0 h1:2dxzU8xJ+ivvqTRph34QX+WrRaJlmfyPqXmoGVjMBa4=
gorm.io/driver/postgres v1.6.0/go.mod h1:vUw0mrGgrTK+uPHEhAdV4sfFELrByKVGnaVRkXDhtWo=
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
gorm.io/driver/sqlite v1.6.0 h1:WHRRrIiulaPiPFmDcod6prc4l2VGVWHz80KspNsxSfQ=
gorm.io/driver/sqlite v1.6.0/go.mod h1:AO9V1qIQddBESngQUKWL9yoH93HIeA1X6V633rBwyT8=
gorm.io/gorm v1.31.2 h1:3o8FXNo9v9S858gil+3LlZA1LkCOzgb4g5BL64FgaCo=
gorm.io/gorm v1.31.2/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
4 changes: 2 additions & 2 deletions agent/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.25.5
require (
github.com/AtlasInsideCorp/AtlasInsideAES v1.0.0
github.com/elastic/go-libaudit/v2 v2.6.2
github.com/elastic/go-sysinfo v1.15.4
github.com/elastic/go-sysinfo v1.15.5
github.com/fsnotify/fsnotify v1.10.1
github.com/glebarez/sqlite v1.11.0
github.com/google/uuid v1.6.0
Expand All @@ -19,7 +19,7 @@ require (
golang.org/x/sys v0.46.0
google.golang.org/grpc v1.81.1
google.golang.org/protobuf v1.36.11
gorm.io/gorm v1.31.1
gorm.io/gorm v1.31.2
)

replace github.com/utmstack/UTMStack/shared => ../shared
Expand Down
12 changes: 8 additions & 4 deletions agent/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ github.com/elastic/go-libaudit/v2 v2.6.2 h1:1PM6wVBTJHJQYsKl8jfA9/Aw9pFty5uUezPi
github.com/elastic/go-libaudit/v2 v2.6.2/go.mod h1:8205nkf2oSrXFlO4H5j8/cyVMoSF3Y7jt+FjgS4ubQU=
github.com/elastic/go-licenser v0.4.1 h1:1xDURsc8pL5zYT9R29425J3vkHdt4RT5TNEMeRN48x4=
github.com/elastic/go-licenser v0.4.1/go.mod h1:V56wHMpmdURfibNBggaSBfqgPxyT1Tldns1i87iTEvU=
github.com/elastic/go-sysinfo v1.15.4 h1:A3zQcunCxik14MgXu39cXFXcIw2sFXZ0zL886eyiv1Q=
github.com/elastic/go-sysinfo v1.15.4/go.mod h1:ZBVXmqS368dOn/jvijV/zHLfakWTYHBZPk3G244lHrU=
github.com/elastic/go-sysinfo v1.15.5 h1:fCVUDmjHgljLUQCygherMnsRRJ9AkuAQIywTL7dEH28=
github.com/elastic/go-sysinfo v1.15.5/go.mod h1:ZBVXmqS368dOn/jvijV/zHLfakWTYHBZPk3G244lHrU=
github.com/elastic/go-windows v1.0.2 h1:yoLLsAsV5cfg9FLhZ9EXZ2n2sQFKeDYrHenkcivY4vI=
github.com/elastic/go-windows v1.0.2/go.mod h1:bGcDpBzXgYSqM0Gx3DM4+UxFj300SZLixie9u9ixLM8=
github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho=
Expand Down Expand Up @@ -93,6 +93,8 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down Expand Up @@ -213,8 +215,10 @@ gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
gorm.io/driver/sqlite v1.6.0 h1:WHRRrIiulaPiPFmDcod6prc4l2VGVWHz80KspNsxSfQ=
gorm.io/driver/sqlite v1.6.0/go.mod h1:AO9V1qIQddBESngQUKWL9yoH93HIeA1X6V633rBwyT8=
gorm.io/gorm v1.31.2 h1:3o8FXNo9v9S858gil+3LlZA1LkCOzgb4g5BL64FgaCo=
gorm.io/gorm v1.31.2/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
howett.net/plist v1.0.1 h1:37GdZ8tP09Q35o9ych3ehygcsL+HqKSwzctveSlarvM=
howett.net/plist v1.0.1/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
modernc.org/cc/v4 v4.27.1 h1:9W30zRlYrefrDV2JE2O8VDtJ1yPGownxciz5rrbQZis=
Expand Down
4 changes: 2 additions & 2 deletions as400/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.25.5

require (
github.com/AtlasInsideCorp/AtlasInsideAES v1.0.0
github.com/elastic/go-sysinfo v1.15.4
github.com/elastic/go-sysinfo v1.15.5
github.com/glebarez/sqlite v1.11.0
github.com/google/uuid v1.6.0
github.com/kardianos/service v1.2.4
Expand All @@ -13,7 +13,7 @@ require (
google.golang.org/grpc v1.81.1
google.golang.org/protobuf v1.36.11
gopkg.in/yaml.v2 v2.4.0
gorm.io/gorm v1.31.1
gorm.io/gorm v1.31.2
)

require (
Expand Down
12 changes: 8 additions & 4 deletions as400/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/elastic/go-sysinfo v1.15.4 h1:A3zQcunCxik14MgXu39cXFXcIw2sFXZ0zL886eyiv1Q=
github.com/elastic/go-sysinfo v1.15.4/go.mod h1:ZBVXmqS368dOn/jvijV/zHLfakWTYHBZPk3G244lHrU=
github.com/elastic/go-sysinfo v1.15.5 h1:fCVUDmjHgljLUQCygherMnsRRJ9AkuAQIywTL7dEH28=
github.com/elastic/go-sysinfo v1.15.5/go.mod h1:ZBVXmqS368dOn/jvijV/zHLfakWTYHBZPk3G244lHrU=
github.com/elastic/go-windows v1.0.2 h1:yoLLsAsV5cfg9FLhZ9EXZ2n2sQFKeDYrHenkcivY4vI=
github.com/elastic/go-windows v1.0.2/go.mod h1:bGcDpBzXgYSqM0Gx3DM4+UxFj300SZLixie9u9ixLM8=
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
Expand Down Expand Up @@ -85,6 +85,8 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down Expand Up @@ -192,8 +194,10 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/gorm v1.31.1 h1:7CA8FTFz/gRfgqgpeKIBcervUn3xSyPUmr6B2WXJ7kg=
gorm.io/gorm v1.31.1/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
gorm.io/driver/sqlite v1.6.0 h1:WHRRrIiulaPiPFmDcod6prc4l2VGVWHz80KspNsxSfQ=
gorm.io/driver/sqlite v1.6.0/go.mod h1:AO9V1qIQddBESngQUKWL9yoH93HIeA1X6V633rBwyT8=
gorm.io/gorm v1.31.2 h1:3o8FXNo9v9S858gil+3LlZA1LkCOzgb4g5BL64FgaCo=
gorm.io/gorm v1.31.2/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M=
howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0=
modernc.org/libc v1.22.5 h1:91BNch/e5B0uPbJFgqbxXuOnxBQjlS//icfQEGmvyjE=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ <h5 class="card-title mb-0 text-uppercase label-header">Incident Response Audit<
<div class="card-header p-2 w-100 d-flex justify-content-between">
<div class="d-flex flex-grow-1">

<ng-select (change)="selectType($event)"
<ng-select [(ngModel)]="selectedOriginType"
(change)="selectType($event)"
[clearable]="true"
[items]="appliedTypes"
[loadingText]="'Loading types....'"
Expand All @@ -19,9 +20,16 @@ <h5 class="card-title mb-0 text-uppercase label-header">Incident Response Audit<
[loading]="!appliedTypes">
</ng-select>

<div class="w-25 ml-3">
<div class="w-25 ml-3" *ngIf="agentSelectVisible">
<app-utm-agent-select (agentSelect)="onAgentSelect($event)" [onlyWithCommands]="true"></app-utm-agent-select>
</div>

<button type="button"
class="btn btn-sm btn-outline-secondary ml-3"
[disabled]="!hasActiveFilters()"
(click)="clearFilters()">
Clear filters
</button>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ export class IncidentResponseViewComponent implements OnInit, OnDestroy {
appliedTypes = [
{label: 'Alert', key: IncidentOriginTypeEnum.ALERT},
{label: 'Incident', key: IncidentOriginTypeEnum.INCIDENT},
{label: 'Incident response', key: IncidentOriginTypeEnum.INCIDENT_RESPONSE},
{label: 'Incident response (manual run)', key: IncidentOriginTypeEnum.INCIDENT_RESPONSE},
{label: 'SOAR flow (automation)', key: IncidentOriginTypeEnum.INCIDENT_RESPONSE_AUTOMATION},
{label: 'SOAR console', key: IncidentOriginTypeEnum.SOAR_CONSOLE},
{label: 'User execution', key: IncidentOriginTypeEnum.USER_EXECUTION},
];
selectedOriginType: IncidentOriginTypeEnum | null = null;
agentSelectVisible = true;

constructor(private incidentResponseJobService: IncidentResponseJobService,
private agentManagerService: UtmAgentManagerService,
Expand Down Expand Up @@ -158,6 +162,24 @@ export class IncidentResponseViewComponent implements OnInit, OnDestroy {
this.requestParams.searchQuery = this.convertParamMapToQueryParam();
this.getAgentCommandList();
}

hasActiveFilters(): boolean {
return this.paramMap.size > 0;
}

clearFilters() {
if (!this.hasActiveFilters()) {
return;
}
this.paramMap.clear();
this.selectedOriginType = null;
this.requestParams.searchQuery = '';
this.requestParams.pageNumber = 1;
this.page = 1;
this.agentSelectVisible = false;
setTimeout(() => this.agentSelectVisible = true);
this.getAgentCommandList();
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ export class PlaybookBuilderComponent implements OnInit, OnDestroy {
this.formRule.get('excludedAgents').setValue(this.rule.excludedAgents);
this.formRule.get('agentType').setValue(this.rule.excludedAgents.length === 0 && this.rule.defaultAgent !== '');
this.formRule.get('defaultAgent').setValue(this.rule.defaultAgent);
this.rule.actions.forEach(action => this.workflowService.addActions(action));
const actionsWithConditional = this.workflowService.inferConditionals(this.rule.command, this.rule.actions);
actionsWithConditional.forEach(action => this.workflowService.addActions(action));

},
error => {
Expand Down Expand Up @@ -203,9 +204,16 @@ export class PlaybookBuilderComponent implements OnInit, OnDestroy {
}
}

syncCommandFromActions() {
const actions = this.workflowService.getActions();
this.formRule.get('actions').setValue(actions);
this.formRule.get('command').setValue(this.workflowService.buildCommand(actions));
}

saveRule() {
const action = 'created';
const actionError = 'creating';
this.syncCommandFromActions();
this.incidentResponseRuleService.create(this.formRule.value)
.subscribe(() => {
this.utmToastService.showSuccessBottom('Flow ' + action + ' successfully');
Expand All @@ -216,7 +224,7 @@ export class PlaybookBuilderComponent implements OnInit, OnDestroy {
editRule() {
const action = 'edited';
const actionError = 'editing';
this.formRule.get('command').setValue(this.command);
this.syncCommandFromActions();
this.incidentResponseRuleService.update(this.formRule.value).subscribe(() => {
this.utmToastService.showSuccessBottom('Flow ' + action + ' successfully');
this.router.navigate(['soar/flows']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ <h4 class="panel-title m-0">Flow Actions</h4>

<div class="workflow-timeline mb-3">

<div *ngFor="let action of workflow; let first = first" class="action-wrapper d-flex flex-column w-100">
<div *ngFor="let action of workflow; let first = first; let i = index" class="action-wrapper d-flex flex-column w-100">
<!-- Action block -->
<div class="action-block cursor-pointer d-flex flex-column w-100 p-2" style="height: 120px;">

Expand All @@ -130,7 +130,7 @@ <h4 class="panel-title m-0">Flow Actions</h4>
<app-action-conditional
*ngIf="!first"
[option]="action.conditional"
(optionChange)="updateAction(action, $event)">
(optionChange)="updateAction(action, i, $event)">
</app-action-conditional>
<div style="min-height: 37px" class="d-flex flex-column justify-content-start icon-cross2 font-size-xs cursor-pointer ml-2"
(click)="removeAction(action)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ export class ActionBuilderComponent implements OnInit, OnDestroy {

}

updateAction(action: any, $event: { key: ActionConditionalEnum; value: string }) {
this.workflowActionsService.updateAction({
updateAction(action: any, index: number, $event: { key: ActionConditionalEnum; value: string }) {
this.workflowActionsService.updateAction(index, {
...action,
conditional: $event
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Component, Input, OnInit} from '@angular/core';
import {Observable} from 'rxjs';
import {filter, tap} from 'rxjs/operators';
import {IncidentOriginTypeEnum} from '../../../../shared/enums/incident-response/incident-origin-type.enum';
import {AgentType} from '../../../../shared/types/agent/agent.type';
import {IncidentCommandType} from '../../../../shared/types/incident/incident-command.type';
import {AgentSidebarService} from '../agent-sidebar/agent-sidebar.service';
Expand All @@ -25,7 +26,7 @@ export class InteractiveConsoleComponent implements OnInit {
this.websocketCommand = {
command: '',
originId: agent.id.toString(),
originType: 'SOAR-CONSOLE',
originType: IncidentOriginTypeEnum.SOAR_CONSOLE,
reason: 'Interactive console command',
};
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,60 @@ export class WorkflowActionsService {
actions$ = this.actionsBehaviorSubject.asObservable();

readonly command$: Observable<string> = this.actions$.pipe(
map(actions => {
if (actions.length === 1) {
return actions[0].command;
map(actions => this.buildCommand(actions))
);

buildCommand(actions: IncidentResponseActionTemplate[] = this.getActions()): string {
if (!actions || actions.length === 0) {
return '';
}

if (actions.length === 1) {
return actions[0].command;
}

return actions.map((action, index) => {
const operator = index === 0 ? ''
: action.conditional.key === ActionConditionalEnum.SUCCESS ? '&&'
: action.conditional.key === ActionConditionalEnum.FAILURE ? '||'
: ';';

return `${operator} ${action.command}`.trim();
}).join(' ').trim();
}

inferConditionals(command: string, actions: IncidentResponseActionTemplate[]): IncidentResponseActionTemplate[] {
if (!actions || actions.length === 0) {
return actions || [];
}

if (!command || actions.length === 1) {
return [{ ...actions[0], conditional: { key: ActionConditionalEnum.ALWAYS, value: ';' } }];
}

const result: IncidentResponseActionTemplate[] = [];
let cursor = 0;

actions.forEach((action, index) => {
const idx = command.indexOf(action.command, cursor);

if (index === 0 || idx === -1) {
result.push({ ...action, conditional: { key: ActionConditionalEnum.ALWAYS, value: ';' } });
} else {
const gap = command.slice(cursor, idx).trim();
const conditional = gap === '&&' ? { key: ActionConditionalEnum.SUCCESS, value: '&&' }
: gap === '||' ? { key: ActionConditionalEnum.FAILURE, value: '||' }
: { key: ActionConditionalEnum.ALWAYS, value: ';' };
result.push({ ...action, conditional });
}

return actions.map((action, index) => {
const operator = index === 0 ? ''
: action.conditional.key === ActionConditionalEnum.SUCCESS ? '&&'
: action.conditional.key === ActionConditionalEnum.FAILURE ? '||'
: ';';
if (idx !== -1) {
cursor = idx + action.command.length;
}
});

return `${operator} ${action.command}`.trim();
}).join(' ').trim();
})
);
return result;
}

addActions(action: any) {
const actions = this.actionsBehaviorSubject.value ? this.actionsBehaviorSubject.value : [];
Expand All @@ -38,18 +77,16 @@ export class WorkflowActionsService {
}]);
}

updateAction(action: any) {
const actions = this.actionsBehaviorSubject.value ? this.actionsBehaviorSubject.value : [];

const index = actions.findIndex((act: any) => act.id === action.id);
updateAction(index: number, action: any) {
const actions = this.getActions();
if (index < 0 || index >= actions.length) {
return;
}

const newActions = [...actions];
newActions[index] = {
...action,
};
newActions[index] = { ...action };

this.actionsBehaviorSubject.next(newActions);

}

deleteAction(action: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export enum IncidentOriginTypeEnum {
DATA_SOURCE = 'DATA_SOURCES',
INCIDENT = 'INCIDENT',
INCIDENT_RESPONSE = 'INCIDENT_RESPONSE',
INCIDENT_RESPONSE_AUTOMATION = 'INCIDENT_RESPONSE_AUTOMATION'
INCIDENT_RESPONSE_AUTOMATION = 'INCIDENT_RESPONSE_AUTOMATION',
SOAR_CONSOLE = 'SOAR-CONSOLE'
}
2 changes: 1 addition & 1 deletion installer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/utmstack/UTMStack/installer
go 1.25.1

require (
github.com/cloudfoundry/gosigar v1.3.121
github.com/cloudfoundry/gosigar v1.3.122
github.com/docker/docker v28.5.2+incompatible
github.com/kardianos/service v1.2.4
github.com/shirou/gopsutil/v3 v3.24.5
Expand Down
Loading
Loading