Compare commits
3 Commits
developmen
...
test/error
Author | SHA1 | Date |
---|---|---|
philipyoo | b29c0617b4 | |
philipyoo | 7d12e4431b | |
philipyoo | 6d565dc7ec |
|
@ -48,12 +48,16 @@ function checkBucketAndKey(bucketName, objectKey, method, reqQuery,
|
||||||
return errors.InvalidBucketName;
|
return errors.InvalidBucketName;
|
||||||
}
|
}
|
||||||
if (objectKey !== undefined) {
|
if (objectKey !== undefined) {
|
||||||
|
console.log('\n\nIn checkBucketAndKey:', objectKey);
|
||||||
const result = routesUtils.isValidObjectKey(objectKey,
|
const result = routesUtils.isValidObjectKey(objectKey,
|
||||||
blacklistedPrefixes.object);
|
blacklistedPrefixes.object);
|
||||||
if (!result.isValid) {
|
if (!result.isValid) {
|
||||||
log.debug('invalid object key', { objectKey });
|
log.debug('invalid object key', { objectKey });
|
||||||
return errors.InvalidArgument.customizeDescription('Object key ' +
|
if (result.invalidPrefix) {
|
||||||
`must not start with "${result.invalidPrefix}".`);
|
return errors.InvalidArgument.customizeDescription('Object ' +
|
||||||
|
`key must not start with "${result.invalidPrefix}".`);
|
||||||
|
}
|
||||||
|
return errors.KeyTooLong;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((reqQuery.partNumber || reqQuery.uploadId)
|
if ((reqQuery.partNumber || reqQuery.uploadId)
|
||||||
|
|
|
@ -874,6 +874,9 @@ const routesUtils = {
|
||||||
if (invalidPrefix) {
|
if (invalidPrefix) {
|
||||||
return { isValid: false, invalidPrefix };
|
return { isValid: false, invalidPrefix };
|
||||||
}
|
}
|
||||||
|
if (objectKey.length > 1024) {
|
||||||
|
return { isValid: false };
|
||||||
|
}
|
||||||
return { isValid: true };
|
return { isValid: true };
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.9.5"
|
"node": ">=6.9.5"
|
||||||
},
|
},
|
||||||
"version": "8.0.0",
|
"version": "8.2.0",
|
||||||
"description": "Common utilities for the S3 project components",
|
"description": "Common utilities for the S3 project components",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
const assert = require('assert');
|
||||||
|
const routesUtils = require('../../../../lib/s3routes/routesUtils.js');
|
||||||
|
|
||||||
|
const bannedStr = 'banned';
|
||||||
|
const prefixBlacklist = [];
|
||||||
|
|
||||||
|
describe('routesUtils.isValidObjectKey', () => {
|
||||||
|
it('should return isValid false if object key name starts with a ' +
|
||||||
|
'blacklisted prefix', () => {
|
||||||
|
const result = routesUtils.isValidObjectKey('bannedkey', [bannedStr]);
|
||||||
|
// return { isValid: false, invalidPrefix };
|
||||||
|
assert.strictEqual(result.isValid, false);
|
||||||
|
assert.strictEqual(result.invalidPrefix, bannedStr);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return isValid false if object key name exceeds length of 1024',
|
||||||
|
() => {
|
||||||
|
const keyLength1025 = 'a'.repeat(1025);
|
||||||
|
const result = routesUtils.isValidObjectKey(keyLength1025,
|
||||||
|
prefixBlacklist);
|
||||||
|
assert.strictEqual(result.isValid, false);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue