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/pslPseudo/pslPseudo.c src/hg/pslPseudo/pslPseudo.c index 7c5de19..bcf13bc 100644 --- src/hg/pslPseudo/pslPseudo.c +++ src/hg/pslPseudo/pslPseudo.c @@ -525,32 +525,32 @@ * ag- */ { dyStringAppendMultiC(aRes, '-', bGap); dyStringAppendN(bRes, bSeq, bGap); dyStringAppendN(aRes, aSeq, aGap); dyStringAppendMultiC(bRes, '-', aGap); } struct axt *pslToAxt(struct psl *psl, struct hash *qHash, struct hash *tHash, struct dlList *fileCache) { static char *tName = NULL, *qName = NULL; static struct dnaSeq *tSeq = NULL, *qSeq = NULL; static struct slName *mrna; -struct dyString *q = newDyString(16*1024); -struct dyString *t = newDyString(16*1024); +struct dyString *q = dyStringNew(16*1024); +struct dyString *t = dyStringNew(16*1024); int blockIx; int qs, ts ; int lastQ = 0, lastT = 0, size; int qOffset = 0; int tOffset = 0; struct axt *axt = NULL; boolean qIsNib = FALSE; boolean tIsNib = FALSE; char name[512]; //int cnt = 0; freeDnaSeq(&qSeq); freez(&qName); assert(mrnaList != NULL); for (mrna = mrnaList; mrna != NULL ; mrna = mrna->next) @@ -2096,32 +2096,32 @@ verbose(2,"#score %s net %d/%d=%d level %d cover %4.1f\n", psl->qName, overlap, netSize,overlap, maxlevel, coverage); overlap = -10; } //overlap = (overlap*100)/(psl->tEnd-psl->tStart); slFreeList(&elist); } return overlap; } void pseudoFeaturesCalc(struct psl *psl, struct psl *bestPsl, int maxExons, int bestAliCount, char *bestChrom, int bestStart, int bestEnd, char *bestStrand) /* calculate features of retroGene */ { struct pseudoGeneLink *pg = NULL; -struct dyString *iString = newDyString(16*1024); -struct dyString *reason = newDyString(255); +struct dyString *iString = dyStringNew(16*1024); +struct dyString *reason = dyStringNew(255); struct genePred *gp = NULL, *kg = NULL, *mgc = NULL; int milliMinPseudo = 1000*minAliPseudo; //int conservedIntrons = 0; //int conservedSpliceSites = 0; int geneOverlap = -1; int polyAstart = 0; int polyAend = 0; int tReps , qReps; int trf = 0, rep = 0; bool keepChecking = TRUE; int intronBases; AllocVar(pg); pg->exonCount = (maxExons*2)-2; /* really splice sites */ pg->bestAliCount = bestAliCount;