44ccfacbe3a3d4b300f80d48651c77837a4b571e galt Tue Apr 26 11:12:02 2022 -0700 SQL INJECTION Prevention Version 2 - this improves our methods by making subclauses of SQL that get passed around be both easy and correct to use. The way that was achieved was by getting rid of the obscure and not well used functions sqlSafefFrag and sqlDyStringPrintfFrag and replacing them with the plain versions of those functions, since these are not needed anymore. The new version checks for NOSQLINJ in unquoted %-s which is used to include SQL clauses, and will give an error the NOSQLINJ clause is not present, and this will automatically require the correct behavior by developers. sqlDyStringPrint is a very useful function, however because it was not enforced, users could use various other dyString functions and they operated without any awareness or checking for SQL correct use. Now those dyString functions are prohibited and it will produce an error if you try to use a dyString function on a SQL string, which is simply detected by the presence of the NOSQLINJ prefix. diff --git src/hg/protein/gadPos/gadPos.c src/hg/protein/gadPos/gadPos.c index 8c3a62f..6bc400c 100644 --- src/hg/protein/gadPos/gadPos.c +++ src/hg/protein/gadPos/gadPos.c @@ -108,32 +108,33 @@ sqlSafef(query, sizeof(query), "select chrom, txStart, txEnd from %s where name2 = '%s'", COMP_TABLE, geneSymbol); found = printBed4FromQueryAndName(conn, query, geneSymbol, outF); } return found; } void gadPos(char *db, char *outFileName) /* Try to get genomic positions for GAD gene symbols from knownGene, refGene, * kgAlias and Gencode V14 in that order. */ { FILE *outF = mustOpen(outFileName, "w"); struct sqlConnection *conn = hAllocConn(db); /* loop over all gene symbols in GAD */ -struct slName *geneSymbols = sqlQuickList(conn, - NOSQLINJ "select distinct geneSymbol from gadAll where association='Y'"); +char query[1024]; +sqlSafef(query, sizeof query, "select distinct geneSymbol from gadAll where association='Y'"); +struct slName *geneSymbols = sqlQuickList(conn, query); struct slName *symbol; int kcCount = 0, rgCount = 0, kaCount = 0, gcCount = 0, missingCount = 0; for (symbol = geneSymbols; symbol != NULL; symbol = symbol->next) { if (findInKnownCanonical(conn, symbol->name, outF)) kcCount++; else if (findInRefGene(conn, symbol->name, outF)) rgCount++; else if (findInKgAlias(conn, symbol->name, outF)) kaCount++; else if (findInGencode(conn, symbol->name, outF)) gcCount++; else { verbose(2, "No result for gene symbol '%s'\n", symbol->name);