A peculiar static code analyzer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) ); | |
} | |
} |