@@ -98,26 +98,56 @@ Function Export-MonkeyData{
9898 ' Scan Date' = $MonkeyExportObject.executionInfo.ScanDate ;
9999 ' Monkey Version' = Get-MonkeyVersion ;
100100 }
101+ # Check if localassetspath has a valid scheme
102+ If ($localHtmlReport -and $localAssetsPath ){
103+ If ($localAssetsPath | Test-IsValidUrl ){
104+ # This assumes that a local CDN is used to serve static files
105+ $msg = @ {
106+ Message = ($message.LocalCDNMessage -f $localAssetsPath );
107+ callStack = (Get-PSCallStack | Select-Object - First 1 );
108+ logLevel = ' verbose' ;
109+ InformationAction = $O365Object.InformationAction ;
110+ Verbose = $O365Object.verbose ;
111+ Tags = @ (' Monkey365LocalCDN' );
112+ }
113+ Write-Verbose @msg
114+ $downloaded = $true
115+ }
116+ }
101117 # Download assets and produce local report
102118 If ($localHtmlReport -and $localAssetsPath -and $assetsRepository ){
103- If (-NOT [System.IO.Path ]::IsPathRooted($O365Object.internal_config.htmlSettings.localHtmlReport.assetsPath )){
104- $localAssetsPath = (" {0}{1}{2}" -f $O365Object.Localpath , [System.IO.Path ]::DirectorySeparatorChar, $O365Object.internal_config.htmlSettings.localHtmlReport.assetsPath )
119+ If ($localAssetsPath | Test-IsValidUrl ){
120+ # This assumes that a local CDN is used to serve static files
121+ $msg = @ {
122+ Message = ($message.LocalCDNMessage -f $localAssetsPath );
123+ callStack = (Get-PSCallStack | Select-Object - First 1 );
124+ logLevel = ' verbose' ;
125+ InformationAction = $O365Object.InformationAction ;
126+ Verbose = $O365Object.verbose ;
127+ Tags = @ (' Monkey365LocalCDN' );
128+ }
129+ Write-Verbose @msg
130+ $downloaded = $true
105131 }
106- $p = @ {
107- Url = $assetsRepository ;
108- SHA256 = $true ;
109- IncludeVersionId = $true ;
110- Output = $localAssetsPath ;
111- Verbose = $O365Object.verbose ;
112- Debug = $O365Object.debug ;
113- InformationAction = $O365Object.InformationAction ;
132+ Else {
133+ If (-NOT [System.IO.Path ]::IsPathRooted($O365Object.internal_config.htmlSettings.localHtmlReport.assetsPath )){
134+ $localAssetsPath = (" {0}{1}{2}" -f $O365Object.Localpath , [System.IO.Path ]::DirectorySeparatorChar, $O365Object.internal_config.htmlSettings.localHtmlReport.assetsPath )
135+ }
136+ $p = @ {
137+ Url = $assetsRepository ;
138+ SHA256 = $true ;
139+ IncludeVersionId = $true ;
140+ Output = $localAssetsPath ;
141+ Verbose = $O365Object.verbose ;
142+ Debug = $O365Object.debug ;
143+ InformationAction = $O365Object.InformationAction ;
144+ }
145+ $downloaded = Update-MonkeyAsset @p
114146 }
115- $downloaded = Update-MonkeyAsset @p
116147 If ($downloaded ){
117148 # Produce report
118149 # Set params
119150 $p = @ {
120- ConfigFile = (" {0}{1}{2}{3}config.json" -f $localAssetsPath , [System.IO.Path ]::DirectorySeparatorChar, " assets" , [System.IO.Path ]::DirectorySeparatorChar);
121151 Report = $matchedRules ;
122152 ExecutionInfo = $O365Object.executionInfo ;
123153 Instance = $O365Object.Instance ;
@@ -128,6 +158,13 @@ Function Export-MonkeyData{
128158 Debug = $O365Object.debug ;
129159 InformationAction = $O365Object.InformationAction ;
130160 }
161+ # If $localAssetsPath is a local URL, monkey365 needs to download the config file before producing report
162+ If ($localAssetsPath | Test-IsValidUrl ){
163+ [void ]$p.Add (' LocalRepository' , $localAssetsPath );
164+ }
165+ Else {
166+ [void ]$p.Add (' ConfigFile' , (" {0}{1}{2}{3}config.json" -f $localAssetsPath , [System.IO.Path ]::DirectorySeparatorChar, " assets" , [System.IO.Path ]::DirectorySeparatorChar));
167+ }
131168 New-HtmlReport @p
132169 }
133170 }
0 commit comments