forked from aquasecurity/cloudsploit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
034998e
commit c1883ed
Showing
6 changed files
with
168 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
var helpers = require('../../../helpers/oracle'); | ||
|
||
module.exports = { | ||
title: 'Cloud Guard Enabled', | ||
category: 'Cloud Guard', | ||
domain: 'Management and Governance', | ||
description: 'Ensure Cloud Guard is enabled in the root compartment of the tenancy.', | ||
more_info: 'Cloud Guard detects misconfigured resources and insecure activity within a tenancy and provides security administrators with the visibility to resolve these issues. Upon detection, Cloud Guard can suggest, assist, or take corrective actions to mitigate these issues.', | ||
recommended_action: 'Cloud Guard should be enabled in the root compartment of your tenancy.', | ||
link: 'https://docs.oracle.com/en-us/iaas/cloud-guard/using/index.htm', | ||
apis: ['cloudguardConfiguration:get'], | ||
|
||
run: function(cache, settings, callback) { | ||
var results = []; | ||
var source = {}; | ||
var region = helpers.objectFirstKey(cache['regionSubscription']['list']); | ||
|
||
if (helpers.checkRegionSubscription(cache, source, results, region)) { | ||
|
||
var config = helpers.addSource(cache, source, | ||
['cloudguardConfiguration', 'get', region]); | ||
|
||
if (!config) return callback(null, results, source); | ||
|
||
if (config.err) { | ||
helpers.addResult(results, 3, | ||
'Unable to query for cloud guard configuration: ' + helpers.addError(config), region); | ||
return callback(null, results, source); | ||
} | ||
if (config.data && Object.keys(config.data).length && config.data.status && config.data.status === 'ENABLED') { | ||
helpers.addResult(results, 0, | ||
'Cloud Guard is enabled in the root compartment of the tenancy.', region); | ||
} else { | ||
helpers.addResult(results, 2, | ||
'Cloud Guard is not enabled in the root compartment of the tenancy.', region); | ||
} | ||
} | ||
callback(null, results, source); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
var expect = require('chai').expect; | ||
var plugin = require('./cloudguardEnabled'); | ||
|
||
const createCache = (err, data) => { | ||
return { | ||
regionSubscription: { | ||
"list": { | ||
"us-ashburn-1": { | ||
"data": [ | ||
{ | ||
"regionKey": "IAD", | ||
"regionName": "us-ashburn-1", | ||
"status": "READY", | ||
"isHomeRegion": true | ||
}, | ||
{ | ||
"regionKey": "LHR", | ||
"regionName": "uk-london-1", | ||
"status": "READY", | ||
"isHomeRegion": false | ||
}, | ||
{ | ||
"regionKey": "PHX", | ||
"regionName": "us-phoenix-1", | ||
"status": "READY", | ||
"isHomeRegion": false | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
|
||
cloudguardConfiguration: { | ||
get: { | ||
'us-ashburn-1': { | ||
err: err, | ||
data: data | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
describe('cloudguardEnabled', function () { | ||
describe('run', function () { | ||
it('should give unknown result if a configuration error is passed or no data is present', function (done) { | ||
const callback = (err, results) => { | ||
expect(results.length).to.be.above(0) | ||
expect(results[0].status).to.equal(3) | ||
expect(results[0].message).to.include('Unable to query for cloud guard configuration') | ||
expect(results[0].region).to.equal('us-ashburn-1') | ||
done() | ||
}; | ||
|
||
const cache = createCache( | ||
['error'], | ||
null, | ||
); | ||
|
||
plugin.run(cache, {}, callback); | ||
}) | ||
|
||
it('should give passing result cloud guard is enabled in the root compartment of the tenancy', function (done) { | ||
const callback = (err, results) => { | ||
expect(results.length).to.be.above(0) | ||
expect(results[0].status).to.equal(0) | ||
expect(results[0].message).to.include('is enabled') | ||
expect(results[0].region).to.equal('us-ashburn-1') | ||
done() | ||
}; | ||
|
||
const cache = createCache( | ||
null, | ||
{ | ||
reportingRegion: 'us-ashburn-1', | ||
status: 'ENABLED', | ||
selfManageResources: false | ||
} | ||
); | ||
|
||
plugin.run(cache, {}, callback); | ||
}) | ||
it('should give failing result if cloud guard is not enabled in the root compartment of the tenancy', function (done) { | ||
const callback = (err, results) => { | ||
expect(results.length).to.be.above(0) | ||
expect(results[0].status).to.equal(2) | ||
expect(results[0].message).to.include('is not enabled') | ||
expect(results[0].region).to.equal('us-ashburn-1') | ||
done() | ||
}; | ||
|
||
const cache = createCache( | ||
null, | ||
{ | ||
reportingRegion: 'us-ashburn-1', | ||
status: 'DISABLED', | ||
selfManageResources: false | ||
} | ||
); | ||
|
||
plugin.run(cache, {}, callback); | ||
}) | ||
}) | ||
}) |