Skip to content

Commit

Permalink
NSFS | NC | Prevent adding additional properties (bucket schema)
Browse files Browse the repository at this point in the history
Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
  • Loading branch information
shirady committed Mar 6, 2024
1 parent 29fc24a commit 0d17ba6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 7 additions & 0 deletions src/manage_nsfs/nsfs_schema_utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Copyright (C) 2023 NooBaa */
'use strict';

const _ = require('lodash');
const RpcError = require('../rpc/rpc_error');
const { default: Ajv } = require('ajv');
const ajv = new Ajv({ verbose: true, allErrors: true });
Expand All @@ -21,6 +22,12 @@ const bucket_schema = require('../server/system_services/schemas/nsfs_bucket_sch
const account_schema = require('../server/system_services/schemas/nsfs_account_schema');
const nsfs_config_schema = require('../server/system_services/schemas/nsfs_config_schema');

_.each(common_api.definitions, schema => {
schema_utils.strictify(schema, {
additionalProperties: false
});
});

schema_utils.strictify(bucket_schema, {
additionalProperties: false
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ describe('schema validation NC NSFS bucket', () => {
assert_validation(bucket_data, reason, message);
});

// GAP - this test should have passing
// currently we can properties to s3_policy which are not part of the schema
it.skip('bucket with my_id inside s3_policy', () => {
it('bucket with my_id inside s3_policy', () => {
const bucket_data = get_bucket_data();
bucket_data.s3_policy = bucket_policy1; // added
bucket_data.s3_policy.my_id = '123'; // this is not part of the schema
Expand All @@ -108,9 +106,7 @@ describe('schema validation NC NSFS bucket', () => {
assert_validation(bucket_data, reason, message);
});

// GAP - this test should have passing
// currently we can properties to encryption which are not part of the schema
it.skip('bucket with my_id inside encryption', () => {
it('bucket with my_id inside encryption', () => {
const bucket_data = get_bucket_data();
bucket_data.encryption = encryption1; // added
bucket_data.encryption.my_id = '123'; // this is not part of the schema
Expand All @@ -120,9 +116,7 @@ describe('schema validation NC NSFS bucket', () => {
assert_validation(bucket_data, reason, message);
});

// GAP - this test should have passing
// currently we can properties to website which are not part of the schema
it.skip('bucket with my_id inside website', () => {
it('bucket with my_id inside website', () => {
const bucket_data = get_bucket_data();
bucket_data.website = website1; // added
bucket_data.website.my_id = '123'; // this is not part of the schema
Expand Down

0 comments on commit 0d17ba6

Please sign in to comment.