Skip to content

Commit

Permalink
fix lint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
agggaurav2024 committed Jan 6, 2025
1 parent 154520c commit 98ea0a6
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,22 @@
function main(organizationId, customModuleDisplayName, locationId = 'global') {
// [START securitycenter_create_security_health_analytics_custom_module]
// npm install '@google-cloud/securitycentermanagement'
const { SecurityCenterManagementClient, protos } = require('@google-cloud/securitycentermanagement');
const {
SecurityCenterManagementClient,
protos,
} = require('@google-cloud/securitycentermanagement');

const client = new SecurityCenterManagementClient();

const EnablementState = protos.google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule.EnablementState;
const Severity = protos.google.cloud.securitycentermanagement.v1.CustomConfig.Severity;
const EnablementState =
protos.google.cloud.securitycentermanagement.v1
.SecurityHealthAnalyticsCustomModule.EnablementState;

const Severity =
protos.google.cloud.securitycentermanagement.v1.CustomConfig.Severity;

/*
* Required. The name of the parent resource of security health analytics module.
* Required. The name of the parent resource of security health analytics module
* Its format is
* `organizations/[organization_id]/locations/[location_id]`
* `folders/[folder_id]/locations/[location_id]`
Expand All @@ -47,14 +54,12 @@ function main(organizationId, customModuleDisplayName, locationId = 'global') {
// define the CEL expression here and this will scans for keys that have not been rotated in
// the last 30 days, change it according to the your requirements
const expr = {
expression: `has(resource.rotationPeriod) && (resource.rotationPeriod > duration('2592000s'))`
expression: `has(resource.rotationPeriod) && (resource.rotationPeriod > duration('2592000s'))`,

Check warning on line 57 in security-center/snippets/management_api/createSecurityHealthAnalyticsCustomModule.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote
};

// define the resource selector
const resourceSelector = {
resourceTypes: [
'cloudkms.googleapis.com/CryptoKey'
]
resourceTypes: ['cloudkms.googleapis.com/CryptoKey'],
};

// define the custom module configuration, update the severity, description,
Expand All @@ -64,7 +69,7 @@ function main(organizationId, customModuleDisplayName, locationId = 'global') {
resourceSelector: resourceSelector,
severity: Severity.MEDIUM,
description: 'add your description here',
recommendation: 'add your recommendation here'
recommendation: 'add your recommendation here',
};

// define the security health analytics custom module configuration, update the
Expand All @@ -73,19 +78,22 @@ function main(organizationId, customModuleDisplayName, locationId = 'global') {
name: name,
displayName: customModuleDisplayName,
enablementState: EnablementState.ENABLED,
customConfig: customConfig
customConfig: customConfig,
};

async function createSecurityHealthAnalyticsCustomModule() {
const [response] = await client.createSecurityHealthAnalyticsCustomModule({
parent: parent,
securityHealthAnalyticsCustomModule: securityHealthAnalyticsCustomModule
securityHealthAnalyticsCustomModule: securityHealthAnalyticsCustomModule,
});
console.log('Security Health Analytics Custom Module creation succeeded: ', response);
console.log(
'Security Health Analytics Custom Module creation succeeded: ',
response
);
}

createSecurityHealthAnalyticsCustomModule();
// [END securitycenter_create_security_health_analytics_custom_module]
}

main(...process.argv.slice(2));
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,36 @@
* Retrieve an existing effective security health analytics custom module
*/
function main(organizationId, customModuleId, locationId = 'global') {
// [START securitycenter_get_effective_security_health_analytics_custom_module]
// npm install '@google-cloud/securitycentermanagement'
const { SecurityCenterManagementClient } = require('@google-cloud/securitycentermanagement');
// [START securitycenter_get_effective_security_health_analytics_custom_module]
// npm install '@google-cloud/securitycentermanagement'
const {
SecurityCenterManagementClient,
} = require('@google-cloud/securitycentermanagement');

const client = new SecurityCenterManagementClient();
const client = new SecurityCenterManagementClient();

/*
* Required. Resource name of security health analytics module.
* Its format is
* `organizations/[organization_id]/locations/[location_id]/effectiveSecurityHealthAnalyticsCustomModules/[custom_module]`
* `folders/[folder_id]/locations/[location_id]/effectiveSecurityHealthAnalyticsCustomModules/[custom_module]`
* `projects/[project_id]/locations/[location_id]/effectiveSecurityHealthAnalyticsCustomModules/[custom_module]`
*/
const name = `organizations/${organizationId}/locations/${locationId}/effectiveSecurityHealthAnalyticsCustomModules/${customModuleId}`;
/*
* Required. Resource name of security health analytics module.
* Its format is
* `organizations/[organization_id]/locations/[location_id]/effectiveSecurityHealthAnalyticsCustomModules/[custom_module]`
* `folders/[folder_id]/locations/[location_id]/effectiveSecurityHealthAnalyticsCustomModules/[custom_module]`
* `projects/[project_id]/locations/[location_id]/effectiveSecurityHealthAnalyticsCustomModules/[custom_module]`
*/
const name = `organizations/${organizationId}/locations/${locationId}/effectiveSecurityHealthAnalyticsCustomModules/${customModuleId}`;

async function getEffectiveSecurityHealthAnalyticsCustomModule() {
const [response] = await client.getEffectiveSecurityHealthAnalyticsCustomModule({
name: name
});
console.log('Security Health Analytics Custom Module get effective succeeded: ', response);
}
async function getEffectiveSecurityHealthAnalyticsCustomModule() {
const [response] =
await client.getEffectiveSecurityHealthAnalyticsCustomModule({
name: name,
});
console.log(
'Security Health Analytics Custom Module get effective succeeded: ',
response
);
}

getEffectiveSecurityHealthAnalyticsCustomModule();
// [END securitycenter_get_effective_security_health_analytics_custom_module]
getEffectiveSecurityHealthAnalyticsCustomModule();
// [END securitycenter_get_effective_security_health_analytics_custom_module]
}

main(...process.argv.slice(2));
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
function main(organizationId, customModuleId, locationId = 'global') {
// [START securitycenter_get_security_health_analytics_custom_module]
// npm install '@google-cloud/securitycentermanagement'
const { SecurityCenterManagementClient } = require('@google-cloud/securitycentermanagement');
const {
SecurityCenterManagementClient,
} = require('@google-cloud/securitycentermanagement');

const client = new SecurityCenterManagementClient();

Expand All @@ -34,13 +36,16 @@ function main(organizationId, customModuleId, locationId = 'global') {

async function getSecurityHealthAnalyticsCustomModule() {
const [response] = await client.getSecurityHealthAnalyticsCustomModule({
name: name
name: name,
});
console.log('Security Health Analytics Custom Module get succeeded: ', response);
console.log(
'Security Health Analytics Custom Module get succeeded: ',
response
);
}

getSecurityHealthAnalyticsCustomModule();
// [END securitycenter_get_security_health_analytics_custom_module]
}

main(...process.argv.slice(2));
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@
function main(organizationId, customModuleId, locationId = 'global') {
// [START securitycenter_update_security_health_analytics_custom_module]
// npm install '@google-cloud/securitycentermanagement'
const { SecurityCenterManagementClient, protos } = require('@google-cloud/securitycentermanagement');
const {
SecurityCenterManagementClient,
protos,
} = require('@google-cloud/securitycentermanagement');

const client = new SecurityCenterManagementClient();

const EnablementState = protos.google.cloud.securitycentermanagement.v1.SecurityHealthAnalyticsCustomModule.EnablementState;
const EnablementState =
protos.google.cloud.securitycentermanagement.v1
.SecurityHealthAnalyticsCustomModule.EnablementState;

/*
* Required. Resource name of security health analytics module.
Expand All @@ -38,26 +43,27 @@ function main(organizationId, customModuleId, locationId = 'global') {
// EnablementState below
const securityHealthAnalyticsCustomModule = {
name: name,
enablementState: EnablementState.DISABLED
enablementState: EnablementState.DISABLED,
};

// Set the field mask to specify which properties should be updated.
const fieldMask = {
paths: [
'enablement_state'
]
}
paths: ['enablement_state'],
};

async function updateSecurityHealthAnalyticsCustomModule() {
const [response] = await client.updateSecurityHealthAnalyticsCustomModule({
updateMask: fieldMask,
securityHealthAnalyticsCustomModule: securityHealthAnalyticsCustomModule
securityHealthAnalyticsCustomModule: securityHealthAnalyticsCustomModule,
});
console.log('Security Health Analytics Custom Module update succeeded: ', response);
console.log(
'Security Health Analytics Custom Module update succeeded: ',
response
);
}

updateSecurityHealthAnalyticsCustomModule();
// [END securitycenter_update_security_health_analytics_custom_module]
}

main(...process.argv.slice(2));
main(...process.argv.slice(2));
Loading

0 comments on commit 98ea0a6

Please sign in to comment.