microsoft / AttackSurfaceAnalyzer

Attack Surface Analyzer can help you analyze your operating system's security configuration for changes during software installation.
MIT License
2.68k stars 271 forks source link

Export Rules to JSON does not work #672

Closed lacyvar closed 1 year ago

lacyvar commented 1 year ago

Clicking on Export Rules to JSON causes an error message on Web client GUI and in the CLI terminal.

To Reproduce

  1. Start the Web client GUI: ...\ASA_win_2.3.290> .\asa gui

  2. In the Web client, navigate to Author page: http://localhost:5000/author

  3. Click on the button Load Embedded Rules --> Embedded rules have been loaded successfully.

  4. Click on the button Export Rules to JSON --> A) The message An error has occurred. This application may no longer respond until reloaded. _Reload_ appears in the Web client GUI, B) and this message appears in the CLI terminal:

    fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111] Unhandled exception in circuit 'p4BsKfPK25Bu9LGOEuXw8ilCX45HWStSLsQm5VXtCco'. Microsoft.JSInterop.JSException: Could not find 'FileSaveAs' ('FileSaveAs' was undefined). Error: Could not find 'FileSaveAs' ('FileSaveAs' was undefined). at http://localhost:5000/_framework/blazor.server.js:1:497 at Array.forEach () at i.findFunction (http://localhost:5000/_framework/blazor.server.js:1:465) at E (http://localhost:5000/_framework/blazor.server.js:1:2606) at http://localhost:5000/_framework/blazor.server.js:1:3494 at new Promise () at kt.beginInvokeJSFromDotNet (http://localhost:5000/_framework/blazor.server.js:1:3475) at http://localhost:5000/_framework/blazor.server.js:1:72077 at Array.forEach () at kt._invokeClientMethod (http://localhost:5000/_framework/blazor.server.js:1:72063) at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args) at Microsoft.CST.AttackSurfaceAnalyzer.Cli.Pages.Author.DownloadRules() in D:\a\1\s\Cli\Pages\Author.razor:line 84 at System.Threading.Tasks.Task.<>c.b__128_0(Object state) at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource`1 completion, SendOrPostCallback d, Object state) at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c.<.cctor>b__23_0(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)

Note: If you click on the Reload, the same issue is coming.

Expected behavior A working feature of exporting rules to a JSON file (with a possibility of specifying the output file name and location).

System Configuration:

gfs commented 1 year ago

Thanks for the report. I have a fix that is working locally in #673 which I expect to merge shortly.

gfs commented 1 year ago

Should be fixed in the latest for the zip releases.

lacyvar commented 1 year ago

After repeating the steps described above, at the step "4. Click on the button Export Rules to JSON", the result is a small file named "Asa-Rules.json" containing only the text "data:text/plain;charset=utf-8,". Thus, it seems the function FileSaveAs gets the filename only and an empty fileContent, even the Rules were loaded before in step 3.