From 38357698cffdfe7439b40993959863dc2961bc92 Mon Sep 17 00:00:00 2001 From: Timo Pollmeier Date: Mon, 1 Jul 2024 15:45:20 +0200 Subject: [PATCH] Use camelCase for capabilities, update exceptions Attributes in Capabilities now use camelCase and exceptions for snake_case in the GMP responses have been added. --- allowedSnakeCase.cjs | 4 +++- src/gmp/capabilities/capabilities.js | 10 +++++----- src/gmp/commands/__tests__/user.js | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/allowedSnakeCase.cjs b/allowedSnakeCase.cjs index 2ba2448ee2..b257daf6f7 100644 --- a/allowedSnakeCase.cjs +++ b/allowedSnakeCase.cjs @@ -206,8 +206,10 @@ module.exports = [ 'general_permissions', 'get_aggregate', 'get_aggregates_response', + 'get_capabilities', 'get_config_family_response', 'get_config_nvt_response', + 'get_features_response', 'get_feeds', 'get_feeds_response', 'get_identifier', @@ -236,13 +238,13 @@ module.exports = [ 'groups_data', 'gsad_response', 'has_av_duration', - '_has_caps', 'has_detection', 'has_duration', 'has_reference', 'has_selected', 'has_severity_filter', 'header_title', + 'help_response', 'highest_severity', 'high_per_host', 'host_allow', diff --git a/src/gmp/capabilities/capabilities.js b/src/gmp/capabilities/capabilities.js index 6b4cf4f760..f8baa0e991 100644 --- a/src/gmp/capabilities/capabilities.js +++ b/src/gmp/capabilities/capabilities.js @@ -52,17 +52,17 @@ const convertType = type => { class Capabilities { constructor(cap_names, featuresList) { - this._has_caps = isDefined(cap_names); - this._has_features = isDefined(featuresList); + this._hasCaps = isDefined(cap_names); + this._hasFeatures = isDefined(featuresList); let caps; let featuresEnabled = {}; - if (this._has_caps) { + if (this._hasCaps) { caps = map(cap_names, name => name.toLowerCase()); } - if (this._has_features) { + if (this._hasFeatures) { forEach(featuresList, feature => { featuresEnabled[feature.name.toUpperCase()] = parseBoolean( feature._enabled, @@ -79,7 +79,7 @@ class Capabilities { } areDefined() { - return this._has_caps; + return this._hasCaps; } has(name) { diff --git a/src/gmp/commands/__tests__/user.js b/src/gmp/commands/__tests__/user.js index e86f86df5d..fe39552f46 100644 --- a/src/gmp/commands/__tests__/user.js +++ b/src/gmp/commands/__tests__/user.js @@ -164,12 +164,12 @@ describe('UserCommand capabilities tests', () => { }, }); - expect(caps._has_caps).toBe(true); + expect(caps._hasCaps).toBe(true); expect(caps.mayAccess('report')).toBe(true); expect(caps.mayAccess('task')).toBe(true); expect(caps.mayAccess('user')).toBe(false); - expect(caps._has_features).toBe(true); + expect(caps._hasFeatures).toBe(true); expect(caps.featureEnabled('test_feature_1')).toBe(true); expect(caps.featureEnabled('TEST_FEATURE_2')).toBe(true); expect(caps.featureEnabled('TEST_FEATURE_3')).toBe(false);