Skip to content

Commit

Permalink
Don’t warn about no https for initial redirect.
Browse files Browse the repository at this point in the history
Avoid flagging an initial http request as insecure if it ends up redirecting to https. A proper http->https redirect setup is a feature, not a bug!
  • Loading branch information
tobli committed May 31, 2018
1 parent 3204186 commit 5c19ed9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/ts/transformers/har-heuristics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ function isSecure(entry: Entry) {
return entry.request.url.indexOf("https://") === 0;
}

function isInitialRedirect(entry: Entry, index: number) {
return index === 0 && !!entry.response.redirectURL;
}

function isPush(entry: Entry): boolean {
if (entry._was_pushed === undefined || entry._was_pushed === null) {
return false;
Expand All @@ -84,7 +88,7 @@ export function documentIsSecure(data: Entry[]) {
}

/** Scans `entry` for noteworthy issues or infos and highlights them */
export function collectIndicators(entry: Entry, docIsTLS: boolean, requestType: RequestType) {
export function collectIndicators(entry: Entry, index: number, docIsTLS: boolean, requestType: RequestType) {
// const harEntry = entry;
const output: WaterfallEntryIndicator[] = [];

Expand All @@ -99,7 +103,7 @@ export function collectIndicators(entry: Entry, docIsTLS: boolean, requestType:
});
}

if (docIsTLS && !isSecure(entry)) {
if (docIsTLS && !(isSecure(entry) || isInitialRedirect(entry, index))) {
output.push({
description: "Insecure request, it should use HTTPS.",
displayType: "icon",
Expand Down
2 changes: 1 addition & 1 deletion src/ts/transformers/har.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function toWaterFallEntry(entry: Entry, index: number, startRelative: number, is
startRelative = Math.round(startRelative);
const endRelative = Math.round(toInt(entry._all_end) || (startRelative + entry.time));
const requestType = mimeToRequestType(entry.response.content.mimeType);
const indicators = collectIndicators(entry, isTLS, requestType);
const indicators = collectIndicators(entry, index, isTLS, requestType);
const responseDetails = createResponseDetails(entry, indicators);
return createWaterfallEntry(entry.request.url,
startRelative,
Expand Down

0 comments on commit 5c19ed9

Please sign in to comment.