31 May 2021

The Checker Framework

 A peculiar static code analyzer.



import org.checkerframework.checker.nullness.qual.*;
import org.checkerframework.checker.tainting.qual.*;
/*
https://checkerframework.org/manual/#installation
javac.bat -processor TaintingChecker CheckerSimplePoc.java
TaintingChecker
FormatterChecker
NullnessChecker
UnitsChecker
RegexChecker
*/
public class CheckerSimplePoc {
private static final String ERROR_MESSAGE_HPAM_NOT_EXISTS = "No existe ningun registro en hpamMarca con id %s";
public static void main( @Tainted String[] args) {
@PolyTainted String aa = "xxxxxx";
String hola = String.format(ERROR_MESSAGE_HPAM_NOT_EXISTS, args[0]);
String hola2 = String.format(ERROR_MESSAGE_HPAM_NOT_EXISTS + aa);
System.out.format( aa );
System.out.format( args[0] );
System.out.println( hola );
System.out.println( String.format("%y", 7) );
// ------------------------
System.out.format(
args[0] + " not valid. HINT: %s",
args[1]
);
}
public void metodo(@Tainted String s) {
String hola = String.format(ERROR_MESSAGE_HPAM_NOT_EXISTS, s);
System.out.format( ERROR_MESSAGE_HPAM_NOT_EXISTS, s );
//System.out.println( String.format("%y", 7) );
}
}

Blog Archive

Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.