Przykład

public class TaintDemoClass {

private String input;

public TaintDemoClass(){

input = getInput();
sensitiveMethod(input);
}

private String getInput(){
// pobierz dane wejściowe od użytkownika...
return aString;
}

private String sanitizeInput(String s) {
// wyczyść dane wejściowe...
return cleanString;
}

private void sensitiveMethod(String s) {
// użyj danych wejściowych...
}

}



Rozwiązanie
Aby uniknąć potencjalnych, szkodliwych efektów niekontrolowanych danych wejściowych we wrażliwych metodach, wysyłaj dane zawsze za pośrednictwem metody sprawdzającej.


public class TaintDemoClass {

private String input;

public TaintDemoClass() {

input = getInput();
String cleanInput = sanitizeInput(input);
sensitiveMethod(cleanInput);
}

private void getInput(){
// pobierz dane wejściowe od użytkownika...
return aString;
}

private String sanitizeInput(String s) {
// wyczyść dane wejściowe...
return cleanString;
}

private void sensitiveMethod(String aString) {
// użyj danych wejściowych...
}

}