Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSFS | NC | Prevent Adding Additional Properties (Bucket Schema) #7830

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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