Skip to content

Commit 80c844c

Browse files
fix[backend](alert_responses): fixed powershell commands syntax errors (#2228)
* fix[backend](alert_responses): fixed powershell commands syntax errors * fix[backend](go_deps): updated go dependencies
1 parent 8b51f2d commit 80c844c

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
6+
7+
<changeSet id="20260615001-1" author="Alex">
8+
<comment>Drop broken duplicate response action templates whose clean equivalents already exist (33→43, 36→38, 37→39).</comment>
9+
<sql dbms="postgresql" splitStatements="true">
10+
<![CDATA[
11+
DELETE FROM public.utm_response_action_template WHERE id IN (33, 36, 37);
12+
]]>
13+
</sql>
14+
</changeSet>
15+
16+
<changeSet id="20260615001-2" author="Alex">
17+
<comment>Fix typo (applicactionname) and remove malformed $($(...)) nesting in template 106.</comment>
18+
<sql dbms="postgresql" splitStatements="false">
19+
<![CDATA[
20+
UPDATE public.utm_response_action_template
21+
SET command = 'powershell ForEach-Object {Start-Process -FilePath ($_.UninstallString -replace ''"([^"]*)".*'', ''$1'') -ArgumentList "/S" -Wait} -InputObject (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -like "*$(target.applicationname)*"})'
22+
WHERE id = 106;
23+
]]>
24+
</sql>
25+
</changeSet>
26+
27+
<changeSet id="20260615001-3" author="Alex">
28+
<comment>Fix bash nested double-quote bug in $(rpm/dpkg | grep ...) for templates 107, 108, 109.</comment>
29+
<sql dbms="postgresql" splitStatements="true">
30+
<![CDATA[
31+
UPDATE public.utm_response_action_template
32+
SET command = 'yum remove -y "$(rpm -qa --queryformat ''%{NAME}\n'' | grep -ixF -- "$(target.applicationname)" | head -1)"'
33+
WHERE id = 107;
34+
35+
UPDATE public.utm_response_action_template
36+
SET command = 'apt-get remove -y "$(dpkg-query -W -f=''${Package}\n'' | grep -ixF -- "$(target.applicationname)" | head -1)"'
37+
WHERE id = 108;
38+
39+
UPDATE public.utm_response_action_template
40+
SET command = 'zypper remove -y "$(rpm -qa --queryformat ''%{NAME}\n'' | grep -ixF -- "$(target.applicationname)" | head -1)"'
41+
WHERE id = 109;
42+
]]>
43+
</sql>
44+
</changeSet>
45+
46+
<changeSet id="20260615001-4" author="Alex">
47+
<comment>Replace tr ' ' '\n' (literal backslash-n inside single quotes) with a self-skip in the loop for templates 122, 123.</comment>
48+
<sql dbms="postgresql" splitStatements="true">
49+
<![CDATA[
50+
UPDATE public.utm_response_action_template
51+
SET command = 'for grp in $(id -nG $(adversary.user)); do [ "$grp" = "$(adversary.user)" ] || gpasswd -d $(adversary.user) "$grp"; done'
52+
WHERE id = 122;
53+
54+
UPDATE public.utm_response_action_template
55+
SET command = 'for grp in $(id -nG $(adversary.user)); do case "$grp" in $(adversary.user)|staff|everyone) ;; *) dseditgroup -o edit -d $(adversary.user) -t user "$grp" 2>/dev/null ;; esac; done'
56+
WHERE id = 123;
57+
]]>
58+
</sql>
59+
</changeSet>
60+
61+
</databaseChangeLog>

backend/src/main/resources/config/liquibase/master.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,4 +599,6 @@
599599

600600
<include file="/config/liquibase/changelog/20260522001_update_socai_custom_headers_password.xml" relativeToChangelogFile="false"/>
601601

602+
<include file="/config/liquibase/changelog/20260615001_fix_response_action_template_syntax.xml" relativeToChangelogFile="false"/>
603+
602604
</databaseChangeLog>

0 commit comments

Comments
 (0)