Skip to content

Commit b3f43c4

Browse files
committed
Merge branch 'develop'
2 parents 3c604e9 + afd3a0e commit b3f43c4

File tree

411 files changed

+25487
-10283
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

411 files changed

+25487
-10283
lines changed

Invoke-Monkey365.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Function Invoke-Monkey365{
5151
SharePoint Online
5252
OneDrive for Business
5353
54-
With Monkey365, there is also support for exporting data driven to popular formats like CSV, XML or JSON.
54+
With Monkey365, there is also support for exporting data driven to popular formats like CSV, CLIXML or JSON.
5555
5656
.NOTES
5757
Author : Juan Garrido
@@ -63,14 +63,14 @@ Function Invoke-Monkey365{
6363
https://github.com/silverhack/monkey365
6464
6565
.EXAMPLE
66-
$assets = Invoke-Monkey365 -ExportTo PRINT -PromptBehavior SelectAccount -IncludeEntraID -Instance Microsoft365 -Analysis SharePointOnline
66+
$assets = Invoke-Monkey365 -ExportTo CSV -PromptBehavior SelectAccount -IncludeEntraID -Instance Microsoft365 -Analysis SharePointOnline
6767
68-
This example retrieves information of both Azure AD and SharePoint Online and print results. If credentials are not supplied, Monkey365 will prompt for credentials.
68+
This example retrieves information of both Azure AD and SharePoint Online and will save results into a CSV file. If credentials are not supplied, Monkey365 will prompt for credentials.
6969
7070
.EXAMPLE
71-
$data = Invoke-Monkey365 -PromptBehavior SelectAccount -Instance Azure -Analysis All -subscriptions 00000000-0000-0000-0000-000000000000 -TenantID 00000000-0000-0000-0000-000000000000 -ExportTo PRINT
71+
Invoke-Monkey365 -PromptBehavior SelectAccount -Instance Azure -Analysis All -subscriptions 00000000-0000-0000-0000-000000000000 -TenantID 00000000-0000-0000-0000-000000000000 -ExportTo CLIXML
7272
73-
This example retrieves information of an Azure subscription and prints results to a local variable. If credentials are not supplied, Monkey365 will prompt for credentials.
73+
This example retrieves information of an Azure subscription and will export data to a XML-based file. If credentials are not supplied, Monkey365 will prompt for credentials.
7474
7575
.EXAMPLE
7676
Invoke-Monkey365 -ClientId 00000000-0000-0000-0000-000000000000 -ClientSecret ("MySuperClientSecret" | ConvertTo-SecureString -AsPlainText -Force) -Instance Azure -Analysis All -subscriptions 00000000-0000-0000-0000-000000000000 -TenantID 00000000-0000-0000-0000-000000000000 -ExportTo CLIXML,CSV,JSON,HTML
@@ -108,7 +108,7 @@ Function Invoke-Monkey365{
108108
All Extract all information about an Azure subscription
109109
110110
.PARAMETER ExportTo
111-
Export data driven to specific formats. Accepted values are CSV, JSON, XML, PRINT, HTML.
111+
Export data driven to specific formats. Accepted values are CSV, JSON, XML, HTML.
112112
113113
.PARAMETER ExcludedResources
114114
Exclude unwanted azure resources from being scanned
@@ -194,7 +194,7 @@ Function Invoke-Monkey365{
194194
[string[]]$ExcludeCollector,
195195

196196
[parameter(Mandatory= $false, HelpMessage= "Export data to multiple formats")]
197-
[ValidateSet("CSV","JSON","CLIXML","PRINT","HTML")]
197+
[ValidateSet("CSV","JSON","CLIXML","HTML")]
198198
[Array]$ExportTo=@(),
199199

200200
[Parameter(HelpMessage="Compress Monkey365 output to a ZIP file")]

collectors/azure/security/securitycontacts/Get-MonkeyAzSecurityContact.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function Get-MonkeyAzSecurityContact {
7979
MessageData = ($message.MonkeyGenericTaskMessage -f $collectorId,"Azure Security Contacts",$O365Object.current_subscription.displayName);
8080
callStack = (Get-PSCallStack | Select-Object -First 1);
8181
logLevel = 'info';
82-
InformationAction = $InformationAction;
82+
InformationAction = $O365Object.InformationAction;
8383
Tags = @('AzureSecContactInfo');
8484
}
8585
Write-Information @msg
@@ -101,6 +101,7 @@ function Get-MonkeyAzSecurityContact {
101101
Id = $account.Id;
102102
location = $account.Id;
103103
Name = $account.Name;
104+
Type = $account.type;
104105
Properties = $account.Properties;
105106
email = $account.Properties.emails;
106107
phone = $account.Properties.phone;

core/html/Invoke-HtmlReport.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ Function Invoke-HtmlReport{
5353
'Monkey Version' = Get-MonkeyVersion;
5454
}
5555
#Check if hashtable
56-
if($MonkeyExportObject.Output -is [hashtable]){
57-
$monkeyData = $MonkeyExportObject.Output | Convert-HashTableToPsObject -psName "Monkey365.Output"
56+
If($MonkeyExportObject.Output -is [hashtable]){
57+
$monkeyData = New-Object -TypeName PsObject -Property $MonkeyExportObject.Output;
5858
}
5959
else{
6060
$monkeyData = $MonkeyExportObject.Output
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ConvertFrom-StringData @'
2+
CliXmlOutputMessage = Exporting CliXml file to "{0}"
3+
SerializationError = Could not serialize {0}: {1}
4+
'@
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ConvertFrom-StringData @'
2+
CliXmlOutputMessage = Exporting CliXml file to "{0}"
3+
SerializationError = Could not serialize {0}: {1}
4+
'@
7.7 KB
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Set-StrictMode -Version Latest #-Version 1.0
2+
3+
$LocalizedDataParams = @{
4+
BindingVariable = 'messages';
5+
BaseDirectory = "{0}/{1}" -f $PSScriptRoot, "Localized";
6+
}
7+
#Import localized data
8+
Import-LocalizedData @LocalizedDataParams;
9+
10+
$listofFiles = [System.IO.Directory]::EnumerateFiles(("{0}" -f $PSScriptRoot),"*.ps1","AllDirectories")
11+
$all_files = $listofFiles.Where({($_ -like "*public*") -or ($_ -like "*private*")})
12+
$all_files.ForEach({. $_})
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Monkey365 - the PowerShell Cloud Security Tool for Azure and Microsoft 365 (copyright 2022) by Juan Garrido
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
function Convert-ObjectToCamelCaseObject{
16+
<#
17+
.SYNOPSIS
18+
19+
.DESCRIPTION
20+
21+
.INPUTS
22+
23+
.OUTPUTS
24+
25+
.EXAMPLE
26+
27+
.NOTES
28+
Author : Juan Garrido
29+
Twitter : @tr1ana
30+
File Name : Convert-ObjectToCamelCaseObject
31+
Version : 1.0
32+
33+
.LINK
34+
https://github.com/silverhack/monkey365
35+
#>
36+
37+
[CmdletBinding()]
38+
Param (
39+
[parameter(Mandatory=$True,ValueFromPipeline = $True, HelpMessage="Object")]
40+
[Object]$InputObject,
41+
42+
[parameter(Mandatory=$false,HelpMessage="Object Name")]
43+
[String]$psName
44+
)
45+
Process{
46+
ForEach($obj in @($InputObject)){
47+
$object = $null
48+
$hashTable = [System.Collections.Specialized.OrderedDictionary]::new()
49+
#check if PsCustomObject
50+
$isPsCustomObject = ([System.Management.Automation.PSCustomObject]).IsAssignableFrom($obj.GetType())
51+
#check if PsObject
52+
$isPsObject = ([System.Management.Automation.PSObject]).IsAssignableFrom($obj.GetType())
53+
If ($isPsCustomObject -or $isPsObject) {
54+
foreach ($element in $obj.Psobject.Properties.GetEnumerator()){
55+
try{
56+
$key = $element.Name | ConvertTo-CamelCase
57+
if($null -eq $element.Value){
58+
[void]$hashTable.Add($key,$element.Value);
59+
}
60+
ElseIf($element.Value.GetType() -eq [System.Management.Automation.PSCustomObject] -or $element.Value.GetType() -eq [System.Management.Automation.PSObject]){
61+
[void]$hashTable.Add($key,(Convert-ObjectToCamelCaseObject -InputObject $element.Value));
62+
}
63+
ElseIf($element.Value.GetType().FullName -like "*OCSF*"){
64+
if($element.Value -is [System.Enum]){
65+
[void]$hashTable.Add($key,$element.Value.value__.ToString());
66+
}
67+
Else{
68+
[void]$hashTable.Add($key,(Convert-ObjectToCamelCaseObject -InputObject ($element.Value | Select-Object *)));
69+
}
70+
}
71+
Else{
72+
if($element.Value -is [System.Enum]){
73+
[void]$hashTable.Add($key,$element.Value.value__.ToString());
74+
}
75+
Else{
76+
[void]$hashTable.Add($key,$element.Value);
77+
}
78+
}
79+
}
80+
Catch{
81+
Write-Error $_
82+
}
83+
}
84+
#Create custom object
85+
$object = New-Object PSObject -Property $hashTable
86+
if($null -ne $object -and $psName){
87+
$object.PSObject.TypeNames.Insert(0,$psName)
88+
}
89+
$object
90+
}
91+
}
92+
}
93+
}

core/modules/monkeyexcel/private/Read-WorkSheetHeaders.ps1 renamed to core/modules/monkeyOutput/private/ConvertTo-CamelCase.ps1

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
Function Read-WorkSheetHeaders{
15+
Function ConvertTo-CamelCase {
1616
<#
1717
.SYNOPSIS
18+
Convert string to camelcase
1819
1920
.DESCRIPTION
21+
Convert string to camelcase
2022
2123
.INPUTS
2224
@@ -27,35 +29,25 @@ Function Read-WorkSheetHeaders{
2729
.NOTES
2830
Author : Juan Garrido
2931
Twitter : @tr1ana
30-
File Name : Read-WorkSheetHeaders
32+
File Name : ConvertTo-CamelCase
3133
Version : 1.0
3234
3335
.LINK
3436
https://github.com/silverhack/monkey365
3537
#>
36-
37-
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Scope="Function")]
38-
[cmdletbinding()]
39-
[OutputType([System.Collections.Hashtable])]
40-
Param (
41-
[parameter(Mandatory=$true, HelpMessage="Work sheet")]
42-
[Alias('Sheet')]
43-
[Object]$MyWorkSheet
38+
[CmdletBinding()]
39+
[OutputType([System.String])]
40+
Param (
41+
[parameter(Mandatory=$true, ValueFromPipeline = $True, HelpMessage="String")]
42+
[String]$InputObject
4443
)
45-
Begin{
46-
$Headers =@{}
47-
$column = 1
48-
}
4944
Process{
50-
Do {
51-
$Header = $MyWorkSheet.cells.item(1,$column).text
52-
If ($Header) {
53-
$Headers.add($Header, $column)
54-
$column++
55-
}
56-
} until (!$Header)
57-
}
58-
End{
59-
return $Headers
45+
$myStr = [regex]::Replace(
46+
$InputObject,
47+
'[-_](\p{L})',
48+
{ $args[0].Groups[1].Value.ToUpper() }
49+
)
50+
$camelCaseStr = $myStr[0].ToString().ToLower(), $myStr.TrimStart($myStr[0]) -join ''
51+
return $camelCaseStr
6052
}
61-
}
53+
}

0 commit comments

Comments
 (0)