a53b9958fa734f73aeffb9ddfe2fbad1ca65f90c galt Mon Jan 30 16:18:41 2017 -0800 Check-in of CSP2 Content-Security-Policy work. All C-language CGIs should now support CSP2 in browser to stop major forms of XSS javascript injection. Javascript on pages is gathered together, and then emitted in a single script block at the end with a nonce that tells the browser, this is js that we generated instead of being injected by a hacker. Both inline script from script blocks and inline js event handlers had to be pulled out and separated. You will not see js sprinkled through-out the page now. Older browsers that support CSP1 or that do not understand CSP at all will still work, just without protection. External js libraries loaded at runtime need to be added to the CSP policy header in src/lib/htmshell.c. diff --git src/hg/hgBlat/hgBlat.c src/hg/hgBlat/hgBlat.c index 6ce2716..f3524be 100644 --- src/hg/hgBlat/hgBlat.c +++ src/hg/hgBlat/hgBlat.c @@ -245,31 +245,34 @@ return diff; } void printLuckyRedirect(char *browserUrl, struct psl *psl, char *database, char *pslName, char *faName, char *uiState, char *unhideTrack) /* Print out a very short page that redirects us. */ { char url[1024]; safef(url, sizeof(url), "%s?position=%s:%d-%d&db=%s&ss=%s+%s&%s%s", browserUrl, psl->tName, psl->tStart + 1, psl->tEnd, database, pslName, faName, uiState, unhideTrack); /* htmlStart("Redirecting"); */ /* Odd it appears that we've already printed the Content-Typ:text/html line but I can't figure out where... */ htmStart(stdout, "Redirecting"); -printf("", url); +char javascript[1024]; +safef(javascript, sizeof javascript, + "location.replace('%s');", url); +jsInline(javascript); printf("", url); htmlEnd(); } static char *replaceSuffix(char *input, char *newSuffix) /* Given a filename with a suffix, replace existing suffix with a new suffix. */ { char buffer[4096]; safecpy(buffer, sizeof buffer, input); char *dot = strrchr(buffer, '.'); safecpy(dot+1, sizeof buffer - 1 - (dot - buffer), newSuffix); return cloneString(buffer); } @@ -870,52 +873,52 @@ organism, feelingLucky); } if(!feelingLucky) cartWebEnd(); gfFileCacheFree(&tFileCache); } void askForSeq(char *organism, char *db) /* Put up a little form that asks for sequence. * Call self.... */ { /* ignore struct serverTable* return, but can error out if not found */ findServer(db, FALSE); /* JavaScript to update form when org changes */ -char *onChangeText = "onchange=\"" +char *onChangeText = "" "document.mainForm.changeInfo.value='orgChange';" - "document.mainForm.submit();\""; + "document.mainForm.submit();"; char *userSeq = NULL; printf( "
\n" "

BLAT Search Genome

\n"); cartSaveSession(cart); puts("\n"); puts("\n"); puts("\n\n"); printf(""); printf(""); printf(""); printf(""); printf(""); printf(""); printf("\n\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n\n"); userSeq = cartUsualString(cart, "userSeq", "");
Genome:Assembly:Query type:Sort output:Output type: 
\n"); -printBlatGenomeListHtml(db, onChangeText); +printBlatGenomeListHtml(db, "change", onChangeText); printf("\n"); printBlatAssemblyListHtml(db); printf("\n"); cgiMakeDropList("type", typeList, ArraySize(typeList), NULL); printf("\n"); cgiMakeDropList("sort", sortList, ArraySize(sortList), cartOptionalString(cart, "sort")); printf("\n"); cgiMakeDropList("output", outputList, ArraySize(outputList), cartOptionalString(cart, "output")); printf("