Add ability to list CWEs in source code

This commit is contained in:
David A. Wheeler 2014-07-13 09:44:34 -04:00
parent c1211121bf
commit 289f341f90
2 changed files with 36 additions and 0 deletions

29
cwe.l Normal file
View File

@ -0,0 +1,29 @@
%{
/* cwe by David A. Wheeler (http://www.dwheeler.com).
This prints anything of the form CWE-#
*/
#include <stdio.h>
#include <ctype.h>
#include <string.h>
void out(char *text) {
fputs(text,stdout);
}
void outchar(char c) {
fputc(c, stdout);
}
%}
%%
CWE-[1-9][0-9]* { out(yytext); outchar('\n'); }
. { }
\n { }
%%

View File

@ -147,6 +147,13 @@ my_install: flawfinder.pdf flawfinder.ps
test.c test2.c test-results.txt test-results.html \
/home/dwheeler/dwheeler.com/flawfinder
# This is intended to be a local capability to list CWEs
show-cwes:
flex -o cwe.c cwe.l
gcc -o cwe cwe.c -lfl
./cwe < flawfinder | sort -u
.PHONY: install clean test check profile test-is-correct rpm uninstall distribute