Skip to content

Commit

Permalink
security-01-fix-code-scanning (#7)
Browse files Browse the repository at this point in the history
* Update .jshintrc

* fix code scanning
  • Loading branch information
andresWeitzel committed Jan 23, 2024
1 parent ba47f0b commit be3afe9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 41 deletions.
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
"esversion": 6,
//https://stackoverflow.com/questions/15894193/disabling-warning-about-require-function-in-jshint
"node": true
}
}
//Fix
38 changes: 19 additions & 19 deletions src/controllers/deleteObject.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"use strict";
'use strict';
//Enums
const { statusCode } = require("../enums/http/statusCode");
const { statusCode } = require('../enums/http/statusCode');
const {
validateHeadersMessage,
} = require("../enums/validation/errors/status-message");
} = require('../enums/validation/errors/status-message');
//Helpers
const { bodyResponse } = require("../helpers/http/bodyResponse");
const { bodyResponse } = require('../helpers/http/bodyResponse');
const {
validateHeadersParams,
} = require("../helpers/validator/http/requestHeadersParams");
const { validateAuthHeaders } = require("../helpers/auth/headers");
const { formatToString } = require("../helpers/format/formatToString");
const { formatToJson } = require("../helpers/format/formatToJson");
} = require('../helpers/validator/http/requestHeadersParams');
const { validateAuthHeaders } = require('../helpers/auth/headers');
const { formatToString } = require('../helpers/format/formatToString');
const { formatToJson } = require('../helpers/format/formatToJson');
const {
initBucketIfEmpty,
} = require("../helpers/bucket/operations/initBucket");
const { readBucket } = require("../helpers/bucket/operations/readBucket");
const { appendBucket } = require("../helpers/bucket/operations/appendBucket");
const { findByUuid } = require("../helpers/bucket/operations/findByUuid");
} = require('../helpers/bucket/operations/initBucket');
const { readBucket } = require('../helpers/bucket/operations/readBucket');
const { appendBucket } = require('../helpers/bucket/operations/appendBucket');
const { findByUuid } = require('../helpers/bucket/operations/findByUuid');
//Const
// validate msg
const HEADERS_PARAMS_ERROR_MESSAGE =
Expand All @@ -27,15 +27,15 @@ const HEADERS_AUTH_ERROR_MESSAGE =
//statu-code
const INTERNAL_SERVER_ERROR_CODE = statusCode.INTERNAL_SERVER_ERROR;
const INTERNAL_SERVER_ERROR_MESSAGE =
"An unexpected error has occurred. The object could not delete from the bucket.";
'An unexpected error has occurred. The object could not delete from the bucket.';
const BAD_REQUEST_CODE = statusCode.BAD_REQUEST;
const BAD_REQUEST_UUID_MESSAGE =
"The object requested from delete is not found inside the bucket according to the uuid ";
'The object requested from delete is not found inside the bucket according to the uuid ';
const BAD_REQUEST_DELETE_OBJECT_MESSAGE =
"The object has been deleted correctly according to the id ";
'The object has been deleted correctly according to the id ';
const UNAUTHORIZED_CODE = statusCode.UNAUTHORIZED;
const OK_CODE = statusCode.OK;
const DELETE_OBJECT_ERROR_DETAIL = "Error in delete-object lambda function.";
const DELETE_OBJECT_ERROR_DETAIL = 'Error in delete-object lambda function.';
//Vars
let eventHeaders;
let validateReqParams;
Expand Down Expand Up @@ -93,7 +93,7 @@ module.exports.handler = async (event) => {
if (obj == null) {
return await bodyResponse(
BAD_REQUEST_CODE,
BAD_REQUEST_UUID_MESSAGE + uuidInput
BAD_REQUEST_UUID_MESSAGE + uuidInput,
);
} else if (obj != null) {
bucketContent = await formatToJson(bucketContent);
Expand All @@ -113,13 +113,13 @@ module.exports.handler = async (event) => {
if (bucketContentResult != null) {
return await bodyResponse(
OK_CODE,
BAD_REQUEST_DELETE_OBJECT_MESSAGE + uuidInput
BAD_REQUEST_DELETE_OBJECT_MESSAGE + uuidInput,
);
}
} else {
return await bodyResponse(
INTERNAL_SERVER_ERROR_CODE,
INTERNAL_SERVER_ERROR_MESSAGE
INTERNAL_SERVER_ERROR_MESSAGE,
);
}
} catch (error) {
Expand Down
40 changes: 20 additions & 20 deletions src/controllers/editObject.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
"use strict";
'use strict';
//Enums
const { statusCode } = require("../enums/http/statusCode");
const { statusCode } = require('../enums/http/statusCode');
const {
validateHeadersMessage,
} = require("../enums/validation/errors/status-message");
} = require('../enums/validation/errors/status-message');
//Helpers
const { bodyResponse } = require("../helpers/http/bodyResponse");
const { bodyResponse } = require('../helpers/http/bodyResponse');
const {
validateHeadersParams,
} = require("../helpers/validator/http/requestHeadersParams");
const { validateAuthHeaders } = require("../helpers/auth/headers");
} = require('../helpers/validator/http/requestHeadersParams');
const { validateAuthHeaders } = require('../helpers/auth/headers');
const {
validateBodyUpdateObjectParams,
} = require("../helpers/validator/http/requestBodyUpdateObjectParams");
const { formatToString } = require("../helpers/format/formatToString");
const { formatToJson } = require("../helpers/format/formatToJson");
} = require('../helpers/validator/http/requestBodyUpdateObjectParams');
const { formatToString } = require('../helpers/format/formatToString');
const { formatToJson } = require('../helpers/format/formatToJson');
const {
initBucketIfEmpty,
} = require("../helpers/bucket/operations/initBucket");
const { readBucket } = require("../helpers/bucket/operations/readBucket");
const { appendBucket } = require("../helpers/bucket/operations/appendBucket");
const { findByUuid } = require("../helpers/bucket/operations/findByUuid");
} = require('../helpers/bucket/operations/initBucket');
const { readBucket } = require('../helpers/bucket/operations/readBucket');
const { appendBucket } = require('../helpers/bucket/operations/appendBucket');
const { findByUuid } = require('../helpers/bucket/operations/findByUuid');
//Const
// validate msg
const HEADERS_PARAMS_ERROR_MESSAGE =
Expand All @@ -30,15 +30,15 @@ const HEADERS_AUTH_ERROR_MESSAGE =
//statu-code
const INTERNAL_SERVER_ERROR_CODE = statusCode.INTERNAL_SERVER_ERROR;
const INTERNAL_SERVER_ERROR_MESSAGE =
"An unexpected error has occurred. The object could not update inside the bucket.";
'An unexpected error has occurred. The object could not update inside the bucket.';
const BAD_REQUEST_CODE = statusCode.BAD_REQUEST;
const BAD_REQUEST_ADD_OBJECT_MESSAGE =
"Bad request, check request attributes. Missing or incorrect";
'Bad request, check request attributes. Missing or incorrect';
const BAD_REQUEST_UUID_MESSAGE =
"The object requested is not found inside the bucket according to the uuid ";
'The object requested is not found inside the bucket according to the uuid ';
const UNAUTHORIZED_CODE = statusCode.UNAUTHORIZED;
const OK_CODE = statusCode.OK;
const EDIT_OBJECT_ERROR_DETAIL = "Error in edit-object lambda function.";
const EDIT_OBJECT_ERROR_DETAIL = 'Error in edit-object lambda function.';
//Vars
let eventBody;
let eventHeaders;
Expand Down Expand Up @@ -95,7 +95,7 @@ module.exports.handler = async (event) => {
if (!validateBodyAddObject) {
return await bodyResponse(
BAD_REQUEST_CODE,
BAD_REQUEST_ADD_OBJECT_MESSAGE
BAD_REQUEST_ADD_OBJECT_MESSAGE,
);
}
// -- end with validation Body ---
Expand All @@ -113,7 +113,7 @@ module.exports.handler = async (event) => {
if (obj == null) {
return await bodyResponse(
BAD_REQUEST_CODE,
BAD_REQUEST_UUID_MESSAGE + uuidInput
BAD_REQUEST_UUID_MESSAGE + uuidInput,
);
} else if (obj != null) {
bucketContent = await formatToJson(bucketContent);
Expand Down Expand Up @@ -142,7 +142,7 @@ module.exports.handler = async (event) => {
} else {
return await bodyResponse(
INTERNAL_SERVER_ERROR_CODE,
INTERNAL_SERVER_ERROR_MESSAGE
INTERNAL_SERVER_ERROR_MESSAGE,
);
}
} catch (error) {
Expand Down
4 changes: 3 additions & 1 deletion src/controllers/getObject.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';
//Enums
const { statusCode } = require('../enums/http/statusCode');
const { validateHeadersMessage } = require('../enums/validation/errors/status-message');
const {
validateHeadersMessage,
} = require('../enums/validation/errors/status-message');
//Helpers
const { bodyResponse } = require('../helpers/http/bodyResponse');
const {
Expand Down

0 comments on commit be3afe9

Please sign in to comment.