Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32222779
D7487.1765205251.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D7487.1765205251.diff
View Options
diff --git a/keyserver/src/utils/validation-utils.js b/keyserver/src/utils/validation-utils.js
--- a/keyserver/src/utils/validation-utils.js
+++ b/keyserver/src/utils/validation-utils.js
@@ -61,7 +61,7 @@
const redactedString = '********';
const redactedTypes = [tPassword, tCookie];
-function sanitizeInput(inputValidator: *, input: *) {
+function sanitizeInput(inputValidator: any, input: any): any {
if (!inputValidator) {
return input;
}
@@ -182,6 +182,9 @@
export {
validateInput,
checkInputValidator,
+ redactedString,
+ sanitizeInput,
+ findFirstInputMatchingValidator,
checkClientSupported,
policiesValidator,
};
diff --git a/keyserver/src/utils/validation-utils.test.js b/keyserver/src/utils/validation-utils.test.js
new file mode 100644
--- /dev/null
+++ b/keyserver/src/utils/validation-utils.test.js
@@ -0,0 +1,27 @@
+// @flow
+
+import t from 'tcomb';
+
+import { tPassword, tShape } from 'lib/utils/validation-utils.js';
+
+import { sanitizeInput, redactedString } from './validation-utils.js';
+
+describe('sanitization', () => {
+ it('should redact a string', () => {
+ expect(sanitizeInput(tPassword, 'password')).toStrictEqual(redactedString);
+ });
+
+ it('should redact a string inside an object', () => {
+ const validator = tShape({ password: tPassword });
+ const object = { password: 'password' };
+ const redacted = { password: redactedString };
+ expect(sanitizeInput(validator, object)).toStrictEqual(redacted);
+ });
+
+ it('should redact an optional string', () => {
+ const validator = tShape({ password: t.maybe(tPassword) });
+ const object = { password: 'password' };
+ const redacted = { password: redactedString };
+ expect(sanitizeInput(validator, object)).toStrictEqual(redacted);
+ });
+});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 8, 2:47 PM (7 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5848256
Default Alt Text
D7487.1765205251.diff (1 KB)
Attached To
Mode
D7487: [keyserver] Add password sanitization tests
Attached
Detach File
Event Timeline
Log In to Comment