forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
win_get_url: ignore defender false positive in tests (ansible#56812)
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
test/integration/targets/win_get_url/library/win_defender_exclusion.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!powershell | ||
|
||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
#Requires -Module Ansible.ModuleUtils.Legacy | ||
|
||
$params = Parse-Args $args -supports_check_mode $true | ||
|
||
$path = Get-AnsibleParam -obj $params -name "path" -type "path" -failifempty $true | ||
$state = Get-AnsibleParam -obj $params -name "state" -type "str" -default "present" -validateset "absent", "present" | ||
|
||
$result = @{ | ||
changed = $false | ||
} | ||
|
||
# This is a test module, just skip instead of erroring out if we cannot set the rule | ||
if ($null -eq (Get-Command -Name Get-MpPreference -ErrorAction SilentlyContinue)) { | ||
$result.skipped = $true | ||
$result.msg = "Skip as cannot set exclusion rule" | ||
Exit-Json -obj $result | ||
} | ||
|
||
$exclusions = (Get-MpPreference).ExclusionPath | ||
if ($null -eq $exclusions) { | ||
$exclusions = @() | ||
} | ||
|
||
if ($state -eq "absent") { | ||
if ($path -in $exclusions) { | ||
Remove-MpPreference -ExclusionPath $path | ||
$result.changed = $true | ||
} | ||
} else { | ||
if ($path -notin $exclusions) { | ||
Add-MpPreference -ExclusionPath $path | ||
$result.changed = $true | ||
} | ||
} | ||
|
||
Exit-Json -obj $result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters