Generic:
OWASP Code Review Guide | OWASP Secure Coding Practices - Quick Reference Guide
C/C++:
CERT C Secure Coding Standard | SEI CERT C++ Coding Standard
libc reference | C Reference Card | C specification
C++ Developer Guidance for Speculative Execution Side Channels
Java:
Oracle Secure Coding Guidelines | CERT: Java Coding Guidelines
Approach/reports/documenting:
Mozilla code audit reports | Qualys Reports
flawfinder
cppcheck
clang analyzer
gcc -Wall -Werror -pedantic -std=[c99 | c1x | c11]
https://frycos.github.io/vulns4free/2022/12/02/rce-in-20-minutes.html
https://github.com/CoolerVoid/heap_detective
semgrep rules for C/C++:
https://github.com/0xdea/semgrep-rules
Setting up cscope & ctags
# setup ctags & cscope
wget http://cscope.sourceforge.net/cscope_maps.vim
mkdir -p /home/fuzz/.vim/plugin/
cp cscope_maps.vim ~/.vim/plugin/
# In src/ dir:
ctags -R ./*
find ./ -name '*.c' -o -name '*.cpp' > cscope.files
cscope -q -R -b -i cscope.files
Usage (cscope)
's' symbol: find all references to the token under cursor (<C-\>s)
'g' global: find global definition(s) of the token under cursor
'c' calls: find all calls to the function name under cursor
't' text: find all instances of the text under cursor
'e' egrep: egrep search for the word under cursor
'f' file: open the filename under cursor
'i' includes: find files that include the filename under cursor
'd' called: find functions that function under cursor calls
Calculating C LoC (removes comments and blank lines)
find ./ -name "*.[ch]" | xargs cat | grep -v '^[[:space:]]*$' | grep -v '^[[:space:]]*\*.*$' | grep -v '^[[:space:]]*//.*$' | wc -l
code formatting tools
http://clang.llvm.org/docs/ClangFormat.html
Line numbers
# show in vim:
:set number
# add (for real to the file):
:%s/^/\=line('.').". "
Block commenting
ctrl-V
select
shift-i
ESC
https://stackoverflow.com/a/1676690