The idea is quite simple, and backwards compatible.
Create a new class of methods, with one and only one mission: Data Validation.
These validation methods accept a list list parameters with a type with the normal parameter list, and their return values is a tuple of (valid or invalid, error message).
The compiler can remove invocations to these validation methods if what has to be validated has already been validated using the tainted analysis.
The compiler can check that the time of these validation methods is always finite doing the same tests as eBPF does.
The validation methods must have documentation.
The rest of the methods could at first and must, when this is well tested, use the names of the validation methods instead of usual types (as the type is already in the parameter list of the validation method, no information is lost).
If the compiler has not removed the validation method call, every time a method is called, the validation method is called, and if it returns invalid, it is treated directly as an Exception.
Examples:
validation isValidId(id: String) {
if (id.isAlpha()) {
return (valid, '');
} else {
return (invalid, ‘invalid id’);
}
}
// Each parameter with a different validation method
public void process_input_data(id: isValidID, url: isURLEscaped, html: isHTMLWithoutJavaScript) {
…
}
// Several paratermets validated in one validation method
public void proces_input_data_2(id, url, html: superValidation, other: isOtherValid) {
…
}
Copyleft Ender. El presente artículo no tiene finalidad informativa, de
creación de opinión pública o de entretenimiento. Tiene como finalidad
principal, la enseñanza y la divulgación de experiencias, proyectos,
pensamientos y conocimientos del autor. Se permite la copia textual, la
traducción y la distribución de este artículo entero en cualquier medio,
a condición de que este aviso sea conservado. Se permite la cita. El
autor no reclamará ninguna cantidad por el ejercicio de las dos
autorizaciones anteriores. No autorizo a ninguna Entidad de Derechos de
Autor a reclamar cantidad alguna en mi nombre por el ejercicio de los
dos derechos anteriores.
No hay comentarios:
Publicar un comentario