Skip to content

Commit

Permalink
addressing cops
Browse files Browse the repository at this point in the history
Apply suggestions from code review

Co-Authored-By: Albert Vaca <[email protected]>
  • Loading branch information
truthbk and albertvaka committed Nov 15, 2019
1 parent 93e1e7e commit e1cb79a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
}
'Windows': {
$agent5_default_repo = '<agent 5 is not supported by this module on windows>' # Param in init.pp so needs to be defined, but not used on Windows
$agent6_default_repo = "https://s3.amazonaws.com/ddagent-windows-stable/"
$agent6_default_repo = 'https://s3.amazonaws.com/ddagent-windows-stable/'
$conf5_dir = 'C:/ProgramData/Datadog/agent5' # Not a real path, but integrations use it to ensure => absent so it needs to be a valid path
$conf6_dir = 'C:/ProgramData/Datadog/conf.d'
$dd_user = 'ddagentuser'
Expand Down
15 changes: 8 additions & 7 deletions manifests/windows/agent6.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@

if $ensure == 'present' {
if ($agent_version in ['6.14.0', '6.14.1']) {
fail("The specified agent version has been blacklisted, please specify a version other than 6.14.0 or 6.14.1")
fail('The specified agent version has been blacklisted, please specify a version other than 6.14.0 or 6.14.1')
}

file { 'installer':
path => $msi_full_path,
source => "${msi_source}",
path => $msi_full_path,
source => $msi_source,
provider => 'windows',
}

exec { 'validate':
command => "\$blacklist = '928b00d2f952219732cda9ae0515351b15f9b9c1ea1d546738f9dc0fda70c336','78b2bb2b231bcc185eb73dd367bfb6cb8a5d45ba93a46a7890fd607dc9188194';\$fileStream = [system.io.file]::openread('${msi_full_path}'); \$hasher = [System.Security.Cryptography.HashAlgorithm]::create('sha256'); \$hash = \$hasher.ComputeHash(\$fileStream); \$fileStream.close(); \$fileStream.dispose();\$hexhash = [system.bitconverter]::tostring(\$hash).ToLower().replace('-','');if (\$hexhash -match \$blacklist) { Exit 1 }",
provider => 'powershell',
command => "\$blacklist = '928b00d2f952219732cda9ae0515351b15f9b9c1ea1d546738f9dc0fda70c336','78b2bb2b231bcc185eb73dd367bfb6cb8a5d45ba93a46a7890fd607dc9188194';\$fileStream = [system.io.file]::openread('${msi_full_path}'); \$hasher = [System.Security.Cryptography.HashAlgorithm]::create('sha256'); \$hash = \$hasher.ComputeHash(\$fileStream); \$fileStream.close(); \$fileStream.dispose();\$hexhash = [system.bitconverter]::tostring(\$hash).ToLower().replace('-','');if (\$hexhash -match \$blacklist) { Exit 1 }",
provider => 'powershell',
logoutput => 'on_failure',
notify => Package[$datadog_agent::params::package_name]
require => File['installer'],
notify => Package[$datadog_agent::params::package_name]
}

package { $datadog_agent::params::package_name:
Expand All @@ -51,7 +52,7 @@
}
} else {
exec { 'datadog_6_14_fix':
command => "((New-Object System.Net.WebClient).DownloadFile('https://s3.amazonaws.com/ddagent-windows-stable/scripts/fix_6_14.ps1', \$env:temp + '\\fix_6_14.ps1')); &\$env:temp\\fix_6_14.ps1",
command => "((New-Object System.Net.WebClient).DownloadFile('https://s3.amazonaws.com/ddagent-windows-stable/scripts/fix_6_14.ps1', \$env:temp + '\\fix_6_14.ps1')); &\$env:temp\\fix_6_14.ps1",
provider => 'powershell',
}

Expand Down

0 comments on commit e1cb79a

Please sign in to comment.