Skip to content

Commit db622ae

Browse files
authored
Merge pull request #219 from bcgov/bugfix/metadata-length
Remove Metadata length constraint and update dependencies
2 parents a584d21 + 238b708 commit db622ae

File tree

11 files changed

+4323
-3492
lines changed

11 files changed

+4323
-3492
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
# Build the application
99
#
10-
FROM registry.access.redhat.com/ubi9/nodejs-18:1-62.1692771036 as builder
10+
FROM registry.access.redhat.com/ubi9/nodejs-18:1-70.1695740477 as builder
1111

1212
ENV NO_UPDATE_NOTIFIER=true
1313

@@ -22,7 +22,7 @@ RUN npm ci --omit=dev
2222
#
2323
# Create the final container image
2424
#
25-
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-67
25+
FROM registry.access.redhat.com/ubi9/nodejs-18-minimal:1-74.1695740475
2626

2727
ENV APP_PORT=3000 \
2828
NO_UPDATE_NOTIFIER=true

app/package-lock.json

Lines changed: 4281 additions & 3460 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
"seed": "knex seed:run"
3030
},
3131
"dependencies": {
32-
"@aws-sdk/client-s3": "^3.388.0",
33-
"@aws-sdk/lib-storage": "^3.388.0",
34-
"@aws-sdk/s3-request-presigner": "^3.388.0",
35-
"api-problem": "^9.0.1",
32+
"@aws-sdk/client-s3": "^3.423.0",
33+
"@aws-sdk/lib-storage": "^3.423.0",
34+
"@aws-sdk/s3-request-presigner": "^3.423.0",
35+
"api-problem": "^9.0.2",
3636
"compression": "^1.7.4",
3737
"config": "^3.3.9",
3838
"content-disposition": "^0.5.4",
@@ -41,22 +41,22 @@
4141
"express": "^4.18.2",
4242
"express-basic-auth": "^1.2.1",
4343
"express-winston": "^4.2.0",
44-
"joi": "^17.10.2",
44+
"joi": "^17.11.0",
4545
"js-yaml": "^4.1.0",
46-
"jsonwebtoken": "^9.0.1",
46+
"jsonwebtoken": "^9.0.2",
4747
"knex": "^2.5.1",
48-
"objection": "^3.1.1",
49-
"pg": "^8.11.2",
48+
"objection": "^3.1.2",
49+
"pg": "^8.11.3",
5050
"winston": "^3.10.0",
5151
"winston-transport": "^4.5.0"
5252
},
5353
"devDependencies": {
5454
"aws-sdk-client-mock": "^3.0.0",
5555
"aws-sdk-client-mock-jest": "^3.0.0",
56-
"eslint": "^8.47.0",
56+
"eslint": "^8.50.0",
5757
"eslint-config-recommended": "^4.1.0",
5858
"eslint-plugin-prettier": "^5.0.0",
59-
"jest": "~29.3.1",
59+
"jest": "^29.7.0",
6060
"jest-joi": "^1.1.17",
6161
"nodemon": "^3.0.1",
6262
"supertest": "^6.3.3"

app/src/components/utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,15 @@ const utils = {
277277

278278
/**
279279
* @function isAtPath
280-
* Predicate function determining if the `path` is a member of the `prefix` path
280+
* Predicate function determining if the `path` is a non-directory member of the `prefix` path
281281
* @param {string} prefix The base "folder"
282282
* @param {string} path The "file" to check
283283
* @returns {boolean} True if path is member of prefix. False in all other cases.
284284
*/
285285
isAtPath(prefix, path) {
286286
if (typeof prefix !== 'string' || typeof path !== 'string') return false;
287287
if (prefix === path) return true; // Matching strings are always at the at the path
288+
if (path.endsWith(DELIMITER)) return false; // Trailing slashes references the folder
288289

289290
const pathParts = path.split(DELIMITER).filter(part => part);
290291
const prefixParts = prefix.split(DELIMITER).filter(part => part);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
exports.up = function (knex) {
2+
return Promise.resolve()
3+
// Change to text type
4+
.then(() => knex.schema.alterTable('metadata', table => {
5+
table.text('key').notNullable().alter();
6+
table.text('value').notNullable().alter();
7+
}));
8+
};
9+
10+
exports.down = function (knex) {
11+
return Promise.resolve()
12+
// Revert back to varchar(255) type
13+
.then(() => knex.schema.alterTable('metadata', table => {
14+
table.string('key', 255).notNullable().alter();
15+
table.string('value', 255).notNullable().alter();
16+
}));
17+
};

app/src/db/models/tables/metadata.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ class Metadata extends Model {
7676
required: ['key', 'value'],
7777
properties: {
7878
id: { type: 'integer' },
79-
key: { type: 'string', minLength: 1, maxLength: 255 },
80-
value: { type: 'string', minLength: 1, maxLength: 255 }
79+
key: { type: 'string', minLength: 1 },
80+
value: { type: 'string', minLength: 1 }
8181
},
8282
additionalProperties: false
8383
};

app/src/docs/v1.api-spec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,10 +1477,10 @@ components:
14771477
description: >-
14781478
An arbitrary metadata key/value pair. Must contain the x-amz-meta-
14791479
prefix to be valid. Multiple metadata pairs can be defined. Keys must be
1480-
unique and will be converted to lowercase.
1480+
unique, contain no whitespace, and will be converted to lowercase.
14811481
schema:
14821482
type: string
1483-
maximum: 255
1483+
minimum: 1
14841484
example:
14851485
- x-amz-meta-foo
14861486
- x-amz-meta-bar

app/src/validators/common.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ const type = {
5050
* @param {number} [options.minValueStringLength=1] Optional minimum string length of metadata value allowed,
5151
* @returns {object} Joi object
5252
*/
53+
// TODO: Simplify by changing from arrow function to property
5354
metadata: ({ minKeyCount = 0, minValueStringLength = 1 } = {}) => Joi.object()
54-
.pattern(/^x-amz-meta-.{1,255}$/i, Joi.string().min(minValueStringLength).max(255), { matches: Joi.array().min(minKeyCount) })
55+
.pattern(/^x-amz-meta-\S+$/i, Joi.string().min(minValueStringLength), { matches: Joi.array().min(minKeyCount) })
5556
.unknown(),
5657

5758
/**
@@ -63,6 +64,7 @@ const type = {
6364
* (default of 9 because COMS also adds a `coms-id` tag by default)
6465
* @returns {object} Joi object
6566
*/
67+
// TODO: Simplify by changing from arrow function to property
6668
tagset: ({ maxKeyCount = 9, minKeyCount = 0, minValueStringLength = 0 } = {}) => Joi.object()
6769
.pattern(
6870
/^(?!coms-id$).{1,255}$/, // don't allow key 'coms-id'

app/tests/unit/components/utils.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,11 @@ describe('isAtPath', () => {
396396
[true, '/foo', 'foo/bar'],
397397
[true, '/foo', '/foo/bar'],
398398
[true, 'a/b', 'a/b/foo.jpg'],
399+
[false, 'a', 'a/b/'], // Trailing slashes references the folder and should be excluded
399400
[false, 'a/b', 'a/b/'], // Trailing slashes references the folder and should be excluded
400401
[false, 'a/b', 'a/b/z/deep.jpg'],
401402
[false, 'a/b', 'a/b/y/z/deep.jpg'],
403+
[false, 'a/b', 'a/b/c/'], // Trailing slashes references the folder and should be excluded
402404
[false, 'a/b/c', 'a/b/c/'], // Trailing slashes references the folder and should be excluded
403405
[false, 'a/b/c', 'a/bar.png'],
404406
[false, 'c/b/a', 'a/b/c/bar.png'],

app/tests/unit/validators/common.spec.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ describe('type', () => {
147147
it('enforces general metadata pattern', () => {
148148
expect(model.patterns).toEqual(expect.arrayContaining([
149149
expect.objectContaining({
150-
regex: '/^x-amz-meta-.{1,255}$/i',
150+
regex: '/^x-amz-meta-\\S+$/i',
151151
rule: expect.objectContaining({
152152
type: 'string',
153153
rules: expect.arrayContaining([
@@ -156,12 +156,6 @@ describe('type', () => {
156156
args: expect.objectContaining({
157157
limit: 1
158158
})
159-
}),
160-
expect.objectContaining({
161-
name: 'max',
162-
args: expect.objectContaining({
163-
limit: 255
164-
})
165159
})
166160
])
167161
})

0 commit comments

Comments
 (0)