SAML-tracer: Export is null on certain conditions

For certain SAML traces it occured to me than the export return an empty file (in fact a file with “null” inside).

An error raises here:

const createFromJSON = function(obj) {
      let stringified = JSON.stringify(obj);
      return JSON.parse(stringified);
    };

    const enrichWithResponse = (req, res) => {
      let responseCopy = createFromJSON(res);
      req.responseStatus = responseCopy.statusCode;
      req.responseStatusText = responseCopy.statusLine;
      req.responseHeaders = responseCopy.responseHeaders;
    };

    let reqscopy = reqs.map(req => {
      let newRequest = createFromJSON(req);
      enrichWithResponse(newRequest, req.getResponse());

      the_filters.forEach(filter => filter(newRequest));
      return newRequest;
    });

When trying to stringify “req.getResponse()” when it returns null.

I wonder if it would be a good solution to alter this:

  'attachHeadersToRequest' : function(request) { // onBeforeSendHeaders
    let uniqueRequestId = new SAMLTrace.UniqueRequestId(request.requestId, request.method, request.url);
    uniqueRequestId.create(id => {
      let tracer = SAMLTrace.TraceWindow.instance();

      // Maybe revise the HTTP method on redirected requests
      let alterationResult = tracer.reviseRedirectedRequestMethod(request, id);
      id = alterationResult.id;

      let entry = tracer.httpRequests.find(req => req.id === id);
      if (!entry) {
        // Skip further execution if no precedingly issued request can be found. This may occur, if tracing
        // new requests is paused. Requests that were issued before pausing will be found and handled.
        return;
      }

      entry.headers = request.requestHeaders;
      tracer.addRequestItem(entry, () => entry.res);
      tracer.updateStatusBar();
    });
  },

In particular: tracer.addRequestItem(entry, () => entry.res); to tracer.addRequestItem(entry, () => entry.res || {}); or so

So the whole trace can be exported dispite one of them acts oddly.

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 22 (11 by maintainers)

Most upvoted comments

@bzbzh Okay, no need for more testing… it is telling though that there’s something odd about certain traces. I’m going to dig on the thread I have re: self-signed cert warnings to see if I can isolate why that gets the null… and maybe we’ll solve your problem as well in the meantime?

@sullivan1337 Missing a bunch of data is to be expected if you filter resources… Perfectly normal behaviour. This ticket is about exporting and then end up with empty files.

I believe I ran into this issue as well, and may have steps to reproduce in Firefox. You can contrive a scenario where this works in the context of a SAML exchange, but it’s equally present on a visit to google.com:

  1. Open up the Web Developer Tools in Firefox and enable Request Blocking (icon looks like 🚫).
  2. Add google.com as a resource to block.
  3. Open SAML Tracer
  4. Back in Firefox, navigate to google.com
  5. Notice in the Network tab any requests to google.com show “Blocked by DevTools”
  6. Notice the corresponding requests in SAML Tracer are grayed out.
  7. Attempt to Export from SAML Tracer. Note that 0 requests can be exported. (if any other entries are present and an export can be accomplished, then re-import it and notice the google.com requests are missing)

This reproduction works because, from my understanding, a bug in Request Blocking in Firefox allows the request to actually be sent but the response is ignored: https://bugzilla.mozilla.org/show_bug.cgi?id=1756770

The real-life use-case where I saw this occurred when JS in the page was cancelling the request before it could ever complete - the request went out, but it was cancelled before the response was received. However, no record of the request could be found in a SAML Tracer export even though it appeared “live” when viewing the network activity there.