sahvx655-wq opened a new pull request, #427:
URL: https://github.com/apache/commons-validator/pull/427

   Following up on #426, I went back through the rest of the check digit 
package looking for the same length hole. ModulusCheckDigit.isValid never 
checks the code length, and calculateModulus weights each character by rightPos 
= length minus index, which does not move when a character is prepended. So the 
routines that weight purely on rightPos accept an over-length code whenever the 
prepended character lands on a no-op weight: ABANumberCheckDigit validates 
0123456780, CUSIPCheckDigit validates 0037833100, and EAN13CheckDigit validates 
a genuine thirteen digit code carrying a leading zero. ISBN10CheckDigit is 
worse because it is modulus 11, so the leading position weight is a multiple of 
the modulus and any prepended digit is swallowed, for example 51930110995. Each 
of these singletons is a public entry point reachable without its wrapper 
validator, so a caller running a code straight through the routine treats the 
padded string as genuine.
   
   The guard sits in each routine's isValid and rejects a code whose length is 
not the fixed length before the check digit test, the same shape merged for 
ISSNCheckDigit and the length guard already present in IBANCheckDigit. Keeping 
it in the routine covers the direct callers, not just the wrapper paths that 
already enforce length through CodeValidator. I deliberately left 
ISINCheckDigit alone since it is length agnostic by design (the 3133EHHF3 
fixture from VALIDATOR-422 is a valid check digit on a non ISIN length), and 
SedolCheckDigit already caps its length; CAS, EC, Verhoeff and Luhn are either 
regex length checked or variable length and so are not affected. Each routine 
gets a regression test that fails before the guard and passes with it.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to