Skip to content

Commit 7be4112

Browse files
committed
Merge branch 'master' into release/current
# Conflicts: # openbas-front/src/admin/components/atomic_testings/atomic_testing/TargetResultsDetail.tsx
2 parents 66c83f5 + 11ffe8d commit 7be4112

File tree

16 files changed

+100
-78
lines changed

16 files changed

+100
-78
lines changed

openbas-api/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.openbas</groupId>
88
<artifactId>openbas-platform</artifactId>
9-
<version>1.18.15</version>
9+
<version>1.18.16</version>
1010
</parent>
1111

1212
<artifactId>openbas-api</artifactId>
@@ -49,7 +49,7 @@
4949
<dependency>
5050
<groupId>io.openbas</groupId>
5151
<artifactId>openbas-framework</artifactId>
52-
<version>1.18.15</version>
52+
<version>1.18.16</version>
5353
</dependency>
5454
<dependency>
5555
<groupId>co.elastic.clients</groupId>
File renamed without changes.
Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
param([string]$arg)
2-
3-
if(-not $arg){ $arg = "NOOP" }
4-
5-
# Clean up URL encoding before anything else
6-
$argClean = $arg.Replace('%3d', '=').Replace('%2b', '+').Replace('%2f', '/')
7-
8-
$command = "-ExecutionPolicy Bypass -WindowStyle Hidden -NonInteractive -NoProfile -Command `"Invoke-Expression ([System.Text.Encoding]::UTF8.GetString([convert]::FromBase64String('$argClean')))`""
9-
10-
Write-Host "[DEBUG] Command: powershell.exe $command"
11-
12-
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument $command
13-
$principal = New-ScheduledTaskPrincipal -UserID "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
14-
$taskName = "OpenBAS-Payload-" + [guid]::NewGuid().ToString()
15-
16-
try {
17-
Register-ScheduledTask -TaskName $taskName -Action $action -Principal $principal -ErrorAction Stop
18-
Write-Host "[OK] Task $taskName registered"
19-
} catch {
20-
Write-Host "[ERROR] Register-ScheduledTask : $($_.Exception.Message)"
21-
}
22-
23-
try {
24-
Start-ScheduledTask -TaskName $taskName -ErrorAction Stop
25-
Write-Host "[OK] Task $taskName started"
26-
} catch {
27-
Write-Host "[ERROR] Start-ScheduledTask : $($_.Exception.Message)"
28-
}
29-
30-
# Wait until the task has actually run
31-
$maxWait = 180 # maximum wait time in seconds
32-
$elapsed = 0
33-
$started = $false
34-
35-
while ($elapsed -lt $maxWait -and -not $started) {
36-
$info = Get-ScheduledTaskInfo -TaskName $taskName -ErrorAction SilentlyContinue
37-
if ($info -and $info.LastRunTime -ne $null) {
38-
Write-Host "[OK] Task $taskName has executed at $($info.LastRunTime)"
39-
$started = $true
40-
} else {
41-
Start-Sleep -Seconds 1
42-
$elapsed++
43-
}
44-
}
45-
46-
if (-not $started) {
47-
Write-Host "[WARN] Task $taskName did not confirm execution within $maxWait seconds"
48-
}
49-
50-
try {
51-
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction Stop
52-
Write-Host "[OK] Task $taskName removed"
53-
} catch {
54-
Write-Host "[ERROR] Unregister-ScheduledTask : $($_.Exception.Message)"
55-
}
1+
param([string]$arg)
2+
3+
if(-not $arg){ $arg = "NOOP" }
4+
5+
# Clean up URL encoding before anything else
6+
$argClean = $arg.Replace('%3d', '=').Replace('%2b', '+').Replace('%2f', '/')
7+
8+
$command = "-ExecutionPolicy Bypass -WindowStyle Hidden -NonInteractive -NoProfile -Command `"Invoke-Expression ([System.Text.Encoding]::UTF8.GetString([convert]::FromBase64String('$argClean')))`""
9+
10+
Write-Host "[DEBUG] Command: powershell.exe $command"
11+
12+
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument $command
13+
$principal = New-ScheduledTaskPrincipal -UserID "SYSTEM" -LogonType ServiceAccount -RunLevel Highest
14+
$taskName = "OpenBAS-Payload-" + [guid]::NewGuid().ToString()
15+
16+
try {
17+
Register-ScheduledTask -TaskName $taskName -Action $action -Principal $principal -ErrorAction Stop
18+
Write-Host "[OK] Task $taskName registered"
19+
} catch {
20+
Write-Host "[ERROR] Register-ScheduledTask : $($_.Exception.Message)"
21+
}
22+
23+
try {
24+
Start-ScheduledTask -TaskName $taskName -ErrorAction Stop
25+
Write-Host "[OK] Task $taskName started"
26+
} catch {
27+
Write-Host "[ERROR] Start-ScheduledTask : $($_.Exception.Message)"
28+
}
29+
30+
# Wait until the task has actually run
31+
$maxWait = 180 # maximum wait time in seconds
32+
$elapsed = 0
33+
$started = $false
34+
35+
while ($elapsed -lt $maxWait -and -not $started) {
36+
$info = Get-ScheduledTaskInfo -TaskName $taskName -ErrorAction SilentlyContinue
37+
if ($info -and $info.LastRunTime -ne $null) {
38+
Write-Host "[OK] Task $taskName has executed at $($info.LastRunTime)"
39+
$started = $true
40+
} else {
41+
Start-Sleep -Seconds 1
42+
$elapsed++
43+
}
44+
}
45+
46+
if (-not $started) {
47+
Write-Host "[WARN] Task $taskName did not confirm execution within $maxWait seconds"
48+
}
49+
50+
try {
51+
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction Stop
52+
Write-Host "[OK] Task $taskName removed"
53+
} catch {
54+
Write-Host "[ERROR] Unregister-ScheduledTask : $($_.Exception.Message)"
55+
}

openbas-api/src/main/java/io/openbas/service/EndpointService.java

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,43 @@ public Endpoint register(final EndpointRegisterInput input) throws IOException {
392392
return endpoint;
393393
}
394394

395+
private void addSourceTagToEndpoint(Endpoint endpoint, AgentRegisterInput input) {
396+
Set<Tag> existingTags =
397+
endpoint.getTags() != null ? new HashSet<>(endpoint.getTags()) : new HashSet<>();
398+
existingTags.removeIf(t -> t.getName() != null && t.getName().startsWith("source:"));
399+
String tagName = "source:" + input.getExecutor().getName().toLowerCase();
400+
Optional<Tag> tag = tagRepository.findByName(tagName);
401+
if (tag.isEmpty()) {
402+
Tag newTag = new Tag();
403+
newTag.setColor(input.getExecutor().getBackgroundColor());
404+
newTag.setName(tagName);
405+
tagRepository.save(newTag);
406+
existingTags.add(newTag);
407+
} else {
408+
existingTags.add(tag.get());
409+
}
410+
endpoint.setTags(existingTags);
411+
}
412+
395413
private Agent updateExistingEndpointAndManageAgent(Endpoint endpoint, AgentRegisterInput input) {
396414
setUpdatedEndpointAttributes(endpoint, input);
415+
addSourceTagToEndpoint(endpoint, input);
397416
updateEndpoint(endpoint);
398417
return createOrUpdateAgent(endpoint, input);
399418
}
400419

420+
private Agent updateExistingAgent(Agent agent, AgentRegisterInput input) {
421+
Endpoint endpoint = (Endpoint) agent.getAsset();
422+
setUpdatedEndpointAttributes(endpoint, input);
423+
addSourceTagToEndpoint(endpoint, input);
424+
updateEndpoint(endpoint);
425+
setUpdatedAgentAttributes(agent, input, endpoint);
426+
return agentService.createOrUpdateAgent(agent);
427+
}
428+
401429
private Agent updateExistingEndpointAndCreateAgent(Endpoint endpoint, AgentRegisterInput input) {
402430
setUpdatedEndpointAttributes(endpoint, input);
431+
addSourceTagToEndpoint(endpoint, input);
403432
updateEndpoint(endpoint);
404433
Agent agent = new Agent();
405434
setNewAgentAttributes(input, agent);
@@ -443,14 +472,6 @@ private void setUpdatedEndpointAttributes(Endpoint endpoint, AgentRegisterInput
443472
EndpointMapper.mergeAddressArrays(endpoint.getMacAddresses(), input.getMacAddresses()));
444473
}
445474

446-
private Agent updateExistingAgent(Agent agent, AgentRegisterInput input) {
447-
Endpoint endpoint = (Endpoint) agent.getAsset();
448-
setUpdatedEndpointAttributes(endpoint, input);
449-
updateEndpoint(endpoint);
450-
setUpdatedAgentAttributes(agent, input, endpoint);
451-
return agentService.createOrUpdateAgent(agent);
452-
}
453-
454475
private void setUpdatedAgentAttributes(Agent agent, AgentRegisterInput input, Endpoint endpoint) {
455476
agent.setAsset(endpoint);
456477
agent.setLastSeen(input.getLastSeen());
@@ -465,6 +486,7 @@ private Agent createNewEndpointAndAgent(AgentRegisterInput input) {
465486
endpoint.setIps(input.getIps());
466487
endpoint.setSeenIp(input.getSeenIp());
467488
endpoint.setMacAddresses(input.getMacAddresses());
489+
addSourceTagToEndpoint(endpoint, input);
468490
createEndpoint(endpoint);
469491
Agent agent = new Agent();
470492
setUpdatedAgentAttributes(agent, input, endpoint);

openbas-framework/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.openbas</groupId>
88
<artifactId>openbas-platform</artifactId>
9-
<version>1.18.15</version>
9+
<version>1.18.16</version>
1010
</parent>
1111

1212
<artifactId>openbas-framework</artifactId>
@@ -17,7 +17,7 @@
1717
<dependency>
1818
<groupId>io.openbas</groupId>
1919
<artifactId>openbas-model</artifactId>
20-
<version>1.18.15</version>
20+
<version>1.18.16</version>
2121
</dependency>
2222
<dependency>
2323
<groupId>com.rabbitmq</groupId>

openbas-front/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openbas-front",
3-
"version": "1.18.15",
3+
"version": "1.18.16",
44
"private": true,
55
"main": "src/index.tsx",
66
"license": "Apache-2.0",

openbas-front/src/admin/components/assets/endpoints/EndpointsDialogAdding.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ const EndpointsDialogAdding: FunctionComponent<Props> = ({
161161
</>
162162
);
163163
} else {
164-
return <span>{t('N/A')}</span>;
164+
return <span>-</span>;
165165
}
166166
},
167167
width: 10,

openbas-front/src/admin/components/atomic_testings/atomic_testing/TargetResultsDetail.tsx

Whitespace-only changes.

openbas-front/src/admin/components/common/endpoints/fragments/EndpointAgentsExecutorsFragment.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const EndpointActiveFragment = (props: Props) => {
2020
});
2121
const { t } = useFormatter();
2222
if (props.endpoint.asset_agents.length <= 0) {
23-
return <span>{t('N/A')}</span>;
23+
return <span>-</span>;
2424
}
2525

2626
const groupedExecutors = getExecutorsCount(props.endpoint, executorsMap);

openbas-front/src/admin/components/payloads/Payloads.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { searchPayloads } from '../../../actions/payloads/payload-actions';
88
import Breadcrumbs from '../../../components/Breadcrumbs';
99
import Drawer from '../../../components/common/Drawer';
1010
import ExportButton from '../../../components/common/ExportButton';
11-
import { buildEmptyFilter } from '../../../components/common/queryable/filter/FilterUtils';
11+
import { buildEmptyFilter, buildFilter } from '../../../components/common/queryable/filter/FilterUtils';
1212
import { initSorting } from '../../../components/common/queryable/Page';
1313
import PaginationComponentV2 from '../../../components/common/queryable/pagination/PaginationComponentV2';
1414
import { buildSearchPagination } from '../../../components/common/queryable/QueryableUtils';
@@ -205,7 +205,7 @@ const Payloads = () => {
205205
filters: [
206206
buildEmptyFilter('payload_attack_patterns', 'contains'),
207207
buildEmptyFilter('payload_platforms', 'contains'),
208-
208+
buildFilter('payload_status', ['Deprecated'], 'not_eq'),
209209
],
210210
},
211211
}));

0 commit comments

Comments
 (0)