Skip to content

Commit

Permalink
update Monkey365 root functions
Browse files Browse the repository at this point in the history
  • Loading branch information
silverhack committed Jun 10, 2024
1 parent d5ea441 commit 39ed2b4
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 27 deletions.
31 changes: 14 additions & 17 deletions Invoke-Monkey365.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,24 @@ Function Invoke-Monkey365{
Begin{
#Set Window name
$Host.UI.RawUI.WindowTitle = "Monkey365 Cloud Security Scanner"
#Start Time
$starttimer = Get-Date
#####Get Default parameters ########
$MyParams = $PSBoundParameters
#Find duplicates in analysis parameter
$duplicateValue = $PSBoundParameters['Analysis'] | Group-Object | Where-Object -Property Count -gt 1
if($duplicateValue){
throw ("[DuplicateValueError] Duplicate values were found: {0}" -f ($duplicateValue.Name -join ', '))
}
#Create O365 object
New-O365Object
#Set timer
$O365Object.startDate = $starttimer
Update-PsObject
#Initialize Logger
Initialize-MonkeyLogger
#Check if import job
if($PSBoundParameters.ContainsKey('ImportJob') -and $PSBoundParameters.ImportJob){
Import-MonkeyJob
return
}
#Check for mandatory params
Test-MandatoryParameter
#Import MSAL module
$msg = @{
MessageData = "Importing MSAL authentication library";
Expand All @@ -428,19 +437,7 @@ Function Invoke-Monkey365{
Write-Information @msg
$MSAL = ("{0}{1}core/modules/monkeymsal" -f $O365Object.Localpath,[System.IO.Path]::DirectorySeparatorChar)
Import-Module $MSAL -Scope Global -Force -ArgumentList $O365Object.forceMSALDesktop
#Start Time
$starttimer = Get-Date
################### End Validate parameters #####################
#Set timer
$O365Object.startDate = $starttimer
Update-PsObject
#Initialize Logger
Initialize-MonkeyLogger
#Check if import job
if($PSBoundParameters.ContainsKey('ImportJob') -and $PSBoundParameters.ImportJob){
Import-MonkeyJob
return
}
#Initialize authentication parameters
Initialize-AuthenticationParam
#Connect
Expand Down
4 changes: 2 additions & 2 deletions monkey365.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ GUID = 'b040dfab-f762-4ce1-bcc4-1b3963603ff1'
Author = 'Juan Garrido'

# Company or vendor of this module
CompanyName = 'Unknown'
CompanyName = 'monkey365'

# Copyright statement for this module
Copyright = '(c)2021 Juan Garrido. All rights reserved.'
Expand Down Expand Up @@ -78,8 +78,8 @@ FunctionsToExport = @(
'Write-Debug',
'Write-Verbose',
'Write-Error',
'Convert-MarkDownToHtml',
'Get-MonkeyJobError'
'Convert-MarkDownToHtml'
)

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
Expand Down
71 changes: 63 additions & 8 deletions monkey365.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $LocalizedDataParams = @{
#Import localized data
Import-LocalizedData @LocalizedDataParams;

<#
$internal_functions = @(
'/core/analysis',
'/core/collector',
Expand All @@ -31,14 +32,31 @@ $internal_functions = @(
'/core/api/m365/SharePointOnline/',
'/core/api/m365/M365AdminPortal/'
)
$all_files = $internal_functions.ForEach({
if([System.IO.Directory]::Exists(("{0}{1}" -f $PSScriptRoot,$_))){
[System.IO.Directory]::EnumerateFiles(("{0}{1}" -f $PSScriptRoot,$_),"*.ps1",[System.IO.SearchOption]::AllDirectories)
}
})
$all_files = $all_files.Where({$_.EndsWith('ps1')})
$all_files.ForEach({. $_})

#>
<#
$internal_functions = @(
'/core/api/auth',
'/core/analysis',
'/core/init',
#'/core/collector',
'/core/utils',
'/core/html',
'/core/tasks',
'/core/watcher',
'/core/import',
#'/core/office',
#'/core/output',
'/core/tenant',
'/core/api/EntraID/graph',
'/core/api/EntraID/msgraph',
'/core/subscription'
# '/core/api/azure/',
#'/core/api/m365/MicrosoftTeams/',
#'/core/api/m365/ExchangeOnline/'
#'/core/api/m365/SharePointOnline/',
#'/core/api/m365/M365AdminPortal/'
)
#>

$internal_modules = @(
'core/modules/monkeyhttpwebrequest'
Expand Down Expand Up @@ -89,5 +107,42 @@ $m365_plugins = Get-MonkeyJob | Receive-MonkeyJob
New-Variable -Name m365_plugins -Value $m365_plugins -Scope Script -Force
#Remove Job
Get-MonkeyJob | Remove-MonkeyJob


$internal_functions = @(
'/core/init',
'/core/utils',
'/core/collector',
'/core/api/auth',
'/core/html',
'/core/office',
'/core/tasks',
'/core/analysis',
'/core/import',
'/core/output',
'/core/api/EntraID/msgraph',
'/core/tenant',
'/core/subscription',
'/core/api/azure',
'/core/api/EntraID/graph/api',
'/core/api/EntraID/graph/helpers/user',
'/core/api/azure/resourcemanagement/api',
'/core/api/azure/resourcemanagement/helpers/tenant',
'/core/api/m365/MicrosoftTeams/',
'/core/api/m365/ExchangeOnline/'
'/core/api/m365/SharePointOnline/',
'/core/api/m365/M365AdminPortal/'
)


$all_files = $internal_functions.ForEach({
if([System.IO.Directory]::Exists(("{0}{1}" -f $PSScriptRoot,$_))){
[System.IO.Directory]::EnumerateFiles(("{0}{1}" -f $PSScriptRoot,$_),"*.ps1",[System.IO.SearchOption]::AllDirectories)
}
})
$all_files = $all_files.Where({$_.EndsWith('ps1')})
$all_files.ForEach({. $_})


$monkey = ("{0}/Invoke-Monkey365.ps1" -f $PSScriptRoot)
. $monkey

0 comments on commit 39ed2b4

Please sign in to comment.