zaproxy / zaproxy

The ZAP core project
https://www.zaproxy.org
Apache License 2.0
12.51k stars 2.24k forks source link

HAR import fails silently #8500

Closed LIttleAncientForestKami closed 2 months ago

LIttleAncientForestKami commented 3 months ago

Describe the bug

Possibly the fault might be in the underlying library but I also wish to point out that UI behaves as it nothing has happened. I did the import twice, for I initially thought that I have perhaps misclicked or something. Logs say that NPE happens. Not sure if this happens for every HAR file or just mine, but I tried a couple.

Steps to reproduce the behavior

  1. Open ZAP
  2. Import HAR file
  3. Nothing happens, no error message

Expected behavior

HAR files is imported or a clear error message tells me what's wrong and if I can do something about that HAR file to have it imported.

Software versions

ZAP 2.15.0, via snap list. zaproxy 2.15.0 32 latest/stable psiinon classic

Java, via java --version: openjdk 11.0.12 2021-07-20 OpenJDK Runtime Environment 18.9 (build 11.0.12+7) OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7, mixed mode)

Ubuntu via inxi: Host: [redacted] Kernel: 6.5.0-35-generic x86_64 bits: 64 compiler: N/A Desktop: GNOME 42.9 (Wayland) tk: GTK 3.24.33 wm: gnome-shell dm: GDM3 42.0 Distro: Ubuntu 22.04.4 LTS (Jammy Jellyfish)

Screenshots

No response

Errors from the zap.log file

2024-05-28 11:51:56,844 [ZAP-Import-Har-1] ERROR UncaughtExceptionLogger - Exception in thread "ZAP-Import-Har-1"
java.lang.NullPointerException: null
    at edu.umass.cs.benchlab.har.HarCustomFields.addHarCustomFields(HarCustomFields.java:122) ~[harlib-1.1.3.jar:?]
    at edu.umass.cs.benchlab.har.HarCustomFields.addHarCustomFields(HarCustomFields.java:130) ~[harlib-1.1.3.jar:?]
    at edu.umass.cs.benchlab.har.HarEntry.<init>(HarEntry.java:197) ~[harlib-1.1.3.jar:?]
    at edu.umass.cs.benchlab.har.HarEntries.<init>(HarEntries.java:86) ~[harlib-1.1.3.jar:?]
    at edu.umass.cs.benchlab.har.HarLog.<init>(HarLog.java:131) ~[harlib-1.1.3.jar:?]
    at edu.umass.cs.benchlab.har.tools.HarFileReader.readHarFile(HarFileReader.java:112) ~[harlib-1.1.3.jar:?]
    at edu.umass.cs.benchlab.har.tools.HarFileReader.readHarFile(HarFileReader.java:87) ~[harlib-1.1.3.jar:?]
    at org.zaproxy.addon.exim.har.MenuImportHar$1.run(MenuImportHar.java:69) ~[?:?]
2024-05-28 11:52:34,859 [ZAP-Import-Har-2] ERROR UncaughtExceptionLogger - Exception in thread "ZAP-Import-Har-2"
java.lang.NullPointerException: null
    at edu.umass.cs.benchlab.har.HarCustomFields.addHarCustomFields(HarCustomFields.java:122) ~[harlib-1.1.3.jar:?]
    at edu.umass.cs.benchlab.har.HarCustomFields.addHarCustomFields(HarCustomFields.java:130) ~[harlib-1.1.3.jar:?]
    at edu.umass.cs.benchlab.har.HarEntry.<init>(HarEntry.java:197) ~[harlib-1.1.3.jar:?]
    at edu.umass.cs.benchlab.har.HarEntries.<init>(HarEntries.java:86) ~[harlib-1.1.3.jar:?]
    at edu.umass.cs.benchlab.har.HarLog.<init>(HarLog.java:131) ~[harlib-1.1.3.jar:?]
    at edu.umass.cs.benchlab.har.tools.HarFileReader.readHarFile(HarFileReader.java:112) ~[harlib-1.1.3.jar:?]
    at edu.umass.cs.benchlab.har.tools.HarFileReader.readHarFile(HarFileReader.java:87) ~[harlib-1.1.3.jar:?]
    at org.zaproxy.addon.exim.har.MenuImportHar$1.run(MenuImportHar.java:69) ~[?:?]

Additional context

HAR was done via Chromium, can be imported by it back or by newest Firefox.

Would you like to help fix this issue?

thc202 commented 3 months ago

Can you provide a sample HAR that reproduces the issue? This will most likely be addressed with zaproxy/zap-extensions#5250.

LIttleAncientForestKami commented 3 months ago

Browser Versions

Chromium (used to export HAR) 125.0.6422.112 (Official Build) snap (64-bit) Revision e099925e675bbb19c42822548f5175ab03a36a32-refs/branch-heads/6422_76@{#3} OS Linux JavaScript V8 12.5.227.9 User Agent Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36

Firefox (used to import HAR): 126.0 (64 bits), May 14th, via snap.

HAR was done via Chromium, can be imported by it back or by newest Firefox. Will try to add a sample.

kingthorin commented 3 months ago

Will try to add a sample.

Thanks @LIttleAncientForestKami I'd like to be sure that it succeeds with the changes I'm working on in zaproxy/zap-extensions#5250

LIttleAncientForestKami commented 3 months ago

Sample

peteris.rocks.har, obtained by visiting https://peteris.rocks/blog/htop/ with Chromium (and with Network tab opened in dev tools)

image

OK, will need to post HAR file in some other manner as it doesn't allow it's upload saying it's unsupported file type.

thc202 commented 3 months ago

Change the extension to .txt.

LIttleAncientForestKami commented 3 months ago

peteris.rocks.har.txt attempt to paste failed, upload as txt seems to be working

and thanks for lighning quick responses and navigation @thc202

kingthorin commented 3 months ago

This is great. Using the code in the PR.