Skip to content

Commit 642922d

Browse files
authored
Merge pull request #799 from jettero/4.0
merge develop forward to 4.0 branch
2 parents 1ced0fa + e69bbf9 commit 642922d

File tree

6 files changed

+66
-26
lines changed

6 files changed

+66
-26
lines changed

hubblestack/daemon.py

+3
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,9 @@ def refresh_grains(initial=False):
798798
hubblestack.utils.signing.__opts__ = __opts__
799799
hubblestack.utils.signing.__salt__ = __salt__
800800

801+
hubblestack.utils.signing.__opts__ = __opts__
802+
hubblestack.utils.signing.__salt__ = __salt__
803+
801804
if not initial and __salt__['config.get']('splunklogging', False):
802805
hubblestack.log.emit_to_splunk(__grains__, 'INFO', 'hubblestack.grains_report')
803806

hubblestack/utils/signing.py

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ def split_certs(fh):
114114
115115
returns a generator, for list, use `list(split_cerst(fh))`
116116
"""
117-
118117
ret = None
119118
for line in fh.readlines():
120119
if ret is None:

pkg/windows/dockerfile

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# 2. docker build -t <image_name> .
55
# The resulting image is ready to run the pyinstaller on container start and drop hubble<version>.exe
66
# in a local directory. Mount c:\data volume into a directory on the host to access the package.
7-
# To run the container:
7+
# To run the container:
88
# 3. Copy over any other items you want to include with hubble and place them in <host folder>/opt
99
# 4. docker run -it --rm -v <host folder>:c:\data <image_name>
1010
#build docker image from windowscore
@@ -31,7 +31,9 @@ VOLUME C:/data
3131
COPY pyinstaller-requirements.txt c:/temp/
3232
COPY hubble.conf C:/temp/
3333
#install Chocolatey, then git and osquery
34-
RUN powershell.exe -Command Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString("$env:CHOCO_URL"))
34+
RUN powershell.exe -Command Set-ExecutionPolicy Bypass -Scope Process -Force; \
35+
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]'Tls,Tls11,Tls12'; \
36+
iex ((New-Object System.Net.WebClient).DownloadString("$env:CHOCO_URL"));
3537
RUN powershell.exe -Command choco install git nssm -y;
3638
RUN powershell.exe -Command choco install osquery --version 3.4.0 -y;
3739

@@ -52,18 +54,18 @@ RUN powershell.exe -Command git clone "$env:HUBBLE_GIT_URL"; \
5254
Push-Location hubble; \
5355
git checkout "$env:HUBBLE_CHECKOUT"; \
5456
pop-location;
55-
57+
5658
#Use pip to install hubble dependencies
5759
RUN powershell.exe -Command pip install -r pyinstaller-requirements.txt;
58-
60+
5961
# Modify gitfs fix for incorrect path variables until fix has been upstreamed
6062
RUN powershell.exe -Command If (!(Test-Path C:/Python27/Lib/site-packages/salt)) {Copy-Item C:/temp/salt/salt -Destination C:/Python27/Lib/site-packages/ -Recurse -Force}; \
6163
$gitfsFile = Get-Content C:\Python27\Lib\site-packages\salt\utils\gitfs.py; \
6264
$gitfsFile = $gitfsFile -replace 'files.add\\(add_mountpoint\\(relpath\\(repo_path\\)\\)\\)','files.add("/".join(repo_path.partition(".:\\")[2].split(os.sep)))'; \
6365
Set-Content -Path C:\Python27\Lib\site-packages\salt\utils\gitfs.py -Value $gitfsFile -Force
6466
#Get vcredist prereq for hubble
6567
RUN powershell.exe -Command \
66-
$ProgressPreference = 'SilentlyContinue'; \
68+
$ProgressPreference = 'SilentlyContinue'; \
6769
Invoke-WebRequest -Uri 'http://repo.saltstack.com/windows/dependencies/64/vcredist_x64_2008_mfc.exe' -OutFile "C:/temp/hubble/pkg/windows/vcredist.exe"
6870
#Create pyionstaller spec and edit it to work with windows
6971
CMD powershell.exe -Command Push-Location C:/temp/hubble; \
@@ -85,11 +87,11 @@ CMD powershell.exe -Command Push-Location C:/temp/hubble; \
8587
If (Test-Path C:/data/hubble.conf) {Copy-Item C:/data/hubble.conf -Destination ./hubble/dist/hubble/etc/hubble/ -Force}; \
8688
If (Test-Path C:/data/opt) {Copy-Item C:/data/opt -Destination './hubble/dist/hubble/' -Recurse -Force}; \
8789
Move-Item 'C:/temp/hubble/pkg/windows/osqueryd_safe_permissions.ps1' -Destination './hubble/dist/hubble/' -Force; \
90+
Move-Item 'C:/temp/hubble/pkg/windows/hubble_config_permissions.ps1' -Destination './hubble/dist/hubble/' -Force; \
8891
Move-Item 'C:/temp/hubble/pkg/windows/prerequisites.ps1' -Destination './hubble/dist/hubble/' -Force; \
8992
#Build the installer
9093
Push-Location 'C:/Program Files (x86)/NSIS'; \
9194
./makensis.exe /DHubbleVersion="$env:HUBBLE_CHECKOUT" 'C:/temp/hubble/pkg/windows/hubble-Setup.nsi'; \
9295
Get-FileHash -Path C:/temp/hubble/pkg/windows/Hubble*exe -Algorithm SHA256 ^| Out-File C:/temp/hubble/pkg/windows/hubble_windows.sha256; \
9396
Copy-Item C:/temp/hubble/pkg/windows/Hubble*exe -Destination C:/data/; \
94-
Copy-Item C:/temp/hubble/pkg/windows/hubble_windows.sha256 -Destination C:/data/;
95-
97+
Copy-Item C:/temp/hubble/pkg/windows/hubble_windows.sha256 -Destination C:/data/;

pkg/windows/hubble-Setup.nsi

+18-17
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@
4646
;Name and File
4747
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
4848
OutFile "Hubble-${PRODUCT_VERSION}-Setup.exe"
49-
49+
5050
;Default Installation folder
5151
InstallDir "C:\${PFILES}\Hubble"
52-
52+
5353
;Get installation folder from registry if available
5454
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
5555
ShowInstDetails show
5656
ShowUnInstDetails show
57-
57+
5858
;Request application privileges for Windows Vista
5959
RequestExecutionLevel highest
6060

@@ -136,7 +136,7 @@
136136

137137
${NSD_CreateText} 0 43u 100% 12u $IndexName_State
138138
Pop $IndexName
139-
139+
140140
${NSD_CreateLabel} 0 60u 100% 12u "Indexer:"
141141
Pop $Label
142142

@@ -146,7 +146,7 @@
146146
nsDialogs::Show
147147

148148
FunctionEnd
149-
149+
150150
Function pageHubbleConfig_Leave
151151

152152
${NSD_GetText} $HECToken $HECToken_State
@@ -172,7 +172,7 @@
172172
SetCtlColors $CheckBox_Hubble_Start "" "ffffff"
173173
# This command required to bring the checkbox to the front
174174
System::Call "User32::SetWindowPos(i, i, i, i, i, i, i) b ($CheckBox_Hubble_Start, ${HWND_TOP}, 0, 0, 0, 0, ${SWP_NOSIZE}|${SWP_NOMOVE})"
175-
175+
176176
# Create Start Hubble Delayed Checkbox
177177
${NSD_CreateCheckbox} 130u 102u 100% 12u "&Delayed Start"
178178
Pop $CheckBox_Hubble_Start_Delayed
@@ -241,13 +241,13 @@
241241
Section "MainSection" SEC01
242242

243243
SetOutPath "$INSTDIR\"
244-
SetOverwrite ifdiff
244+
SetOverwrite ifdiff
245245
CreateDirectory $INSTDIR\var
246246
CreateDirectory $INSTDIR\etc\hubble\hubble.d
247247
File /r "..\..\dist\hubble\"
248248

249249
SectionEnd
250-
250+
251251
Section -Post
252252

253253
WriteUninstaller "$INSTDIR\uninst.exe"
@@ -287,20 +287,21 @@
287287

288288
ExecWait 'powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File .\prerequisites.ps1 "$INSTDIR" -FFFeatureOff'
289289
ExecWait 'powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File .\osqueryd_safe_permissions.ps1 "$INSTDIR" -FFFeatureOff'
290+
ExecWait 'powershell -ExecutionPolicy Bypass -WindowStyle Hidden -File .\hubble_config_permissions.ps1 "$INSTDIR" -FFFeatureOff'
290291
RMDir /R "$INSTDIR\var\cache" ; removing cache from old version
291292

292293
${if} $HECToken_State != "xxxxx-xxx-xxx-xxx-xxxxxx"
293294
${AndIf} $HECToken_State != ""
294295
Call makeUserConfig
295296
${endif}
296-
297+
297298
Push "C:\${PFILES}\Hubble"
298299
Call AddToPath
299300

300301
Delete "$INSTDIR\vcredist.exe"
301302

302303
SectionEnd
303-
304+
304305
Section Uninstall
305306

306307
Call un.uninstallHubble
@@ -387,7 +388,7 @@
387388
"$(^Name) was successfully removed from your computer." \
388389
/SD IDOK
389390
FunctionEnd
390-
391+
391392

392393
;--------------------------------
393394
;functions
@@ -446,7 +447,7 @@
446447
skipUninstall:
447448

448449
FunctionEnd
449-
450+
450451
Function .onInstSuccess
451452

452453
; If StartHubbleDelayed is 1, then set the service to start delayed
@@ -460,7 +461,7 @@
460461
${EndIf}
461462

462463
FunctionEnd
463-
464+
464465
;--------------------------------
465466
;Helper Functions Section
466467

@@ -706,11 +707,11 @@
706707
!macroend
707708
!insertmacro RemoveFromPath ""
708709
!insertmacro RemoveFromPath "un."
709-
710+
710711
;--------------------------------
711712
;Specialty Fuctions
712713
Function makeUserConfig
713-
714+
714715
confFind:
715716
IfFileExists "$INSTDIR\etc\hubble\hubble.d\user.conf" confFound confNotFound
716717

@@ -725,7 +726,7 @@
725726
goto confFind
726727

727728
confLoop:
728-
729+
729730
FileWrite $9 "hubblestack:$\r$\n"
730731
FileWrite $9 " returner:$\r$\n"
731732
FileWrite $9 " splunk:$\r$\n"
@@ -789,7 +790,7 @@ Function parseCommandLineSwitches
789790
${ElseIf} $IndexName_State == ""
790791
StrCpy $IndexName_State "index"
791792
${EndIf}
792-
793+
793794
# Hubble Config: Indexer
794795
${GetOptions} $R0 "/indexer=" $R1
795796
${IfNot} $R1 == ""
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
$hubble_path = $args[0]
2+
$hubble_conf_path = $hubble_path + "\etc\hubble\"
3+
Write-Host $hubble_conf_path
4+
$acl = Get-Acl $hubble_conf_path
5+
6+
$acl.SetAccessRuleProtection($true, $false)
7+
foreach ($access in $acl.Access) {
8+
$acl.RemoveAccessRule($access)
9+
}
10+
Set-Acl $hubble_conf_path $acl
11+
Write-Host "Succesfully removed all permissions from file"
12+
13+
$acl = Get-Acl $hubble_conf_path
14+
$inheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::ContainerInherit -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit
15+
$propagationFlag = [System.Security.AccessControl.PropagationFlags]::None
16+
$permType = [System.Security.AccessControl.AccessControlType]::Allow
17+
$grantedPerm = 'FullControl'
18+
19+
$systemSid = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-18')
20+
$systemUser = $systemSid.Translate([System.Security.Principal.NTAccount])
21+
Write-Host $systemUser
22+
23+
$adminsSid = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-32-544')
24+
$adminsGroup = $adminsSid.Translate([System.Security.Principal.NTAccount])
25+
Write-Host $adminsGroup
26+
27+
$permGroups = @($systemUser, $adminsGroup)
28+
foreach ($accnt in $permGroups) {
29+
$permission = $accnt.Value, $grantedPerm, $inheritanceFlag, $propagationFlag, $permType
30+
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
31+
Write-Host $accessRule
32+
$acl.SetAccessRule($accessRule)
33+
}
34+
$acl.SetOwner($adminsGroup)
35+
Set-Acl $hubble_conf_path $acl

pkg/windows/pyinstaller-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pprint
77
daemon
88
boto3
99
botocore
10-
pygit2
10+
pygit2<0.27.0
1111
gitpython
1212
cffi
1313
azure==4.0.0

0 commit comments

Comments
 (0)