Commit 48cb2ad
* MySQLCodec Underscore Escape Tests
Implementing my understanding of the desired tests from the issue.
* MySQLCodec Logic and Test Modifications
I am not sure this is what is desired
Tests showing the MySQLCodec acts as specified for the OWASP
recommendation of MySQL encoding for both ANSI and MySQL (Standard) Modes.
Logic updates to account for divergence from the recommended approach.
* MySQLCodec Logic (Restoring)
Putting back the logic from MySQLCodec removed last commit. Alphanumerics
under 256 should be returned in their original forms based on OWASP
recommendation being targeted.
* MySQLCodec Test Updates
Correcting tests for the STANDARD handling of characters up to 256
including numbers, upper/lower case letters, special encoded characters,
and any value outside the previously defined sets.
This should now assert the OWASP recommended approach to Encoding STANDARD
MySQL inputs.
* MySQLCodecTest Updates: DECODE
Adding a decode validation to the existing tests to verify that when an
ecoded string is decoded that the original value is the result.
* MySQLCodec Logic Update: Bug Fix
Identified a case in MySQLCodec (STANDARD) where the special-case
character 0x1a was correctly encoding to '//Z', but the decode case was
watching for '//z'. Encoded value did not decode to original input.
Logic update in decode to alter the lower case z to the upper-case Z.
* MySQLCodec Documentation Update
Updating the URL listed in the class documentation to direct to OWASP
recommended MySQL Escaping.
* MySQLCodecTest Updates Ansi Decode PB_Seq
Adding workflow & behavioral validations for the ANSI handling of decoding
a PushBackSequence reference.
* MySQLCodecTest Updates Ansi Decode PB_Seq
Updating ANSI PushbackSequence tests names to be
better self-documenting.
* MySQLCodecTest Updates Standard Decode PB_Seq
Adding tests for Standard MySQLCodec Decode with PushbackSequence
* MySqlCodecTest Ctr using int
The ctr is deprecated, but still should be tested as long as it is
present. Adding cases for ANSI and Standard resolution showing mode is
correctly resolved. Stub of an unsupported int also included, but
currently ignored.
* MySQLCodec Logic & Tests invalid int CTR Arg
Found that implementations would throw NPE's if an invalid int was
provided to the deprecated constructor when trying to encode or decode
values. Opted to alter the constructor logic to immediately throw a
runtime exception (IllegalArgument) if the constructor parameter cannot
resolve to a valid reference.
It would be a Runtime exception either way, it's just a matter of when
it's thrown.
Alternatively, the mode switches in the encode/decode could have been
surrounded by an if block with an else/fallthrough which retuned null.
It is my opinion that this is a non-obvious failure of misconfiguration
and would be difficult to diagnose and resolve. The immediate class
failure should provide the end-user with context on how to resolve the
problem and limit the time debugging.
Tests provided to validate workflow.
* MySQLCodecTest Update Method Rename
Renaming static method to be inclusive of the creation of both mode escape
maps.
* MySQLCodec Test Immunity Validations
Tests for handling of encoding with immunity sets for STANDARD and ANSI
modes.
* MySQLCodec Documentation Updates
Updating class documentation to clarify the intended support provided by
the implementation.
* MySQLCodec Code Structure Updates
Making a copy of MySQLCodec in its own subpackage of the codec group. Breaking
apart the implementation into the codec and a strategy pattern controlled
by the MySQLMode enumeration.
Each piece of this implementation retained the original tests; however,
like the code, the tests have been split up as well. Now the
responsibilty of the ANSI handing is in the MySQLAnsiSupport class.
Standard behavior is held an tested from the MySQLStandardSupport class.
I feel like this change increases readability and usability of the
baseline. I am committing this at this time to get another set of
opinions on this approach. In the interim, the original MySQLCodec and
tests have remained untouched in this effort.
* Cleanup: Removing MySqlCodec Strategy impl
Sample served its purpose and may be revisited later. Opting to maintain
existing implementation for issue resolution.
* Updating documentation: ANSI_QUOTES Mode
Providing javadoc mapping from the MySQLCodec ANSI mode to the MySQL
Server ANSI_QUOTES mode documentation.
* Removing testMySQLANSIModeQuoteInjection
From research, on issue #31 double quotes within the single quote literals
supported in ANSI_QUOTE modes do not require explicit escape handling.
* Reintroducing testMySQLANSIModeQuoteInjection
Updating compare to match current expectation and adding comment to
clarify that no special handling for double quotes is needed in
ANSI_QUOTES mode.
1 parent f68341f commit 48cb2ad
File tree
3 files changed
+421
-13
lines changed- src
- main/java/org/owasp/esapi/codecs
- test/java/org/owasp/esapi
- codecs
- reference
3 files changed
+421
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
23 | 30 | | |
24 | | - | |
25 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
26 | 54 | | |
27 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
28 | 62 | | |
29 | 63 | | |
30 | 64 | | |
| |||
46 | 80 | | |
47 | 81 | | |
48 | 82 | | |
49 | | - | |
| 83 | + | |
| 84 | + | |
50 | 85 | | |
51 | 86 | | |
52 | 87 | | |
53 | 88 | | |
54 | 89 | | |
55 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
56 | 97 | | |
57 | 98 | | |
58 | 99 | | |
| |||
100 | 141 | | |
101 | 142 | | |
102 | 143 | | |
| 144 | + | |
103 | 145 | | |
104 | 146 | | |
105 | 147 | | |
| 148 | + | |
106 | 149 | | |
107 | | - | |
108 | 150 | | |
109 | 151 | | |
110 | 152 | | |
| |||
123 | 165 | | |
124 | 166 | | |
125 | 167 | | |
126 | | - | |
127 | | - | |
| 168 | + | |
128 | 169 | | |
129 | 170 | | |
130 | 171 | | |
| |||
166 | 207 | | |
167 | 208 | | |
168 | 209 | | |
| 210 | + | |
169 | 211 | | |
170 | | - | |
171 | 212 | | |
172 | 213 | | |
173 | 214 | | |
| |||
244 | 285 | | |
245 | 286 | | |
246 | 287 | | |
247 | | - | |
| 288 | + | |
248 | 289 | | |
249 | 290 | | |
250 | 291 | | |
| |||
0 commit comments