<commit_before>#!powershell
# This file is part of Ansible
#
# Copyright 2015, <NAME> <<EMAIL>>
# Copyright 2015, <NAME>
# Copyright 2015, <NAME> <<EMAIL>>
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
 
# WANT_JSON
# POWERSHELL_COMMON
 
# win_acl module (File/Resources Permission Additions/Removal)
 
 
#Functions
Function UserSearch
{
    Param ([string]$AccountName)
    #Check if there's a realm specified
    if ($AccountName.Split("\").count -gt 1)
    {
        if ($AccountName.Split("\")[0] -eq $env:COMPUTERNAME)
        {
            $IsLocalAccount = $true
        }
        Else
        {
            $IsDomainAccount = $true
            $IsUpn = $false
        }
 
    }
    Elseif ($AccountName -contains "@")
    {
        $IsDomainAccount = $true
        $IsUpn = $true
    }
    Else
    {
        #Default to local user account
        $accountname = $env:COMPUTERNAME + "\" + $AccountName
        $IsLocalAccount = $true
    }
 
 
    if ($IsLocalAccount -eq $true)
    {
        # do not use Win32_UserAccount, because e.g. SYSTEM (BUILTIN\SYSTEM or COMPUUTERNAME\SYSTEM) will not be listed. on Win32_Account groups will be listed too
        $localaccount = get-wmiobject -class "Win32_Account" -namespace "root\CIMV2" -filter "(LocalAccount = True)" | where {$_.Caption -eq $AccountName}
        if ($localaccount)
        {
            return $localaccount.SID
        }
    }
    ElseIf (($IsDomainAccount -eq $true) -and ($IsUpn -eq $false))
    {
        #Search by samaccountname
        $Searcher = [adsisearcher]""
        $Searcher.Filter = "sAMAccountName=$($accountname.split("\")[1])"
        $result = $Searcher.FindOne()
 
        if ($result)
        {
            $user = $result.GetDirectoryEntry()

            # get binary SID from AD account
            $binarySID = $user.ObjectSid.Value

            # convert to string SID
            return (New-Object System.Security.Principal.SecurityIdentifier($binarySID,0)).Value
        }
    }
 
}
 
$params = Parse-Args $args;

$result = New-Object PSObject;
Set-Attr $result "changed" $false;

$path = Get-Attr $params "path" -failifempty $true
$user = Get-Attr $params "user" -failifempty $true
$rights = Get-Attr $params "rights" -failifempty $true

$type = Get-Attr $params "type" -validateSet "allow","deny" -resultobj $result
$state = Get-Attr $params "state" "present" -validateSet "present","absent" -resultobj $result

$inherit = Get-Attr $params "inherit" ""
$propagation = Get-Attr $params "propagation" "None" -validateSet "None","NoPropagateInherit","InheritOnly" -resultobj $result

If (-Not (Test-Path -Path $path)) {
    Fail-Json $result "$path file or directory does not exist on the host"
}
<commit_msg>fail if type parameter is empty<commit_after>#!powershell
# This file is part of Ansible
#
# Copyright 2015, <NAME> <<EMAIL>>
# Copyright 2015, <NAME>
# Copyright 2015, <NAME> <<EMAIL>>
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
 
# WANT_JSON
# POWERSHELL_COMMON
 
# win_acl module (File/Resources Permission Additions/Removal)
 
 
#Functions
Function UserSearch
{
    Param ([string]$AccountName)
    #Check if there's a realm specified
    if ($AccountName.Split("\").count -gt 1)
    {
        if ($AccountName.Split("\")[0] -eq $env:COMPUTERNAME)
        {
            $IsLocalAccount = $true
        }
        Else
        {
            $IsDomainAccount = $true
            $IsUpn = $false
        }
 
    }
    Elseif ($AccountName -contains "@")
    {
        $IsDomainAccount = $true
        $IsUpn = $true
    }
    Else
    {
        #Default to local user account
        $accountname = $env:COMPUTERNAME + "\" + $AccountName
        $IsLocalAccount = $true
    }
 
 
    if ($IsLocalAccount -eq $true)
    {
        # do not use Win32_UserAccount, because e.g. SYSTEM (BUILTIN\SYSTEM or COMPUUTERNAME\SYSTEM) will not be listed. on Win32_Account groups will be listed too
        $localaccount = get-wmiobject -class "Win32_Account" -namespace "root\CIMV2" -filter "(LocalAccount = True)" | where {$_.Caption -eq $AccountName}
        if ($localaccount)
        {
            return $localaccount.SID
        }
    }
    ElseIf (($IsDomainAccount -eq $true) -and ($IsUpn -eq $false))
    {
        #Search by samaccountname
        $Searcher = [adsisearcher]""
        $Searcher.Filter = "sAMAccountName=$($accountname.split("\")[1])"
        $result = $Searcher.FindOne()
 
        if ($result)
        {
            $user = $result.GetDirectoryEntry()

            # get binary SID from AD account
            $binarySID = $user.ObjectSid.Value

            # convert to string SID
            return (New-Object System.Security.Principal.SecurityIdentifier($binarySID,0)).Value
        }
    }
 
}
 
$params = Parse-Args $args;

$result = New-Object PSObject;
Set-Attr $result "changed" $false;

$path = Get-Attr $params "path" -failifempty $true
$user = Get-Attr $params "user" -failifempty $true
$rights = Get-Attr $params "rights" -failifempty $true

$type = Get-Attr $params "type" -failifempty $true -validateSet "allow","deny" -resultobj $result
$state = Get-Attr $params "state" "present" -validateSet "present","absent" -resultobj $result

$inherit = Get-Attr $params "inherit" ""
$propagation = Get-Attr $params "propagation" "None" -validateSet "None","NoPropagateInherit","InheritOnly" -resultobj $result

If (-Not (Test-Path -Path $path)) {
    Fail-Json $result "$path file or directory does not exist on the host"
}

{'fraction_non_alphanumeric': 0.11620517476168861, 'fraction_numerical': 0.007262823422605538, 'mean_word_length': 2.8186019641825535, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5518055', 'n_tokens_mistral': 2086, 'n_tokens_neox': 1979, 'n_words': 643}