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

feature/AKD-190: Added Google BigQuery Dataset All Users Policy plugin and test cases #676

Merged
merged 135 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from 134 commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
e1708af
SPLOIT-113: Added Plain Text Parameters plugin for CloudFormation
AkhtarAmir Aug 12, 2020
2122ade
Added vpcEndpointAcceptance plugin and spec file
AkhtarAmir Aug 13, 2020
306d721
SPLOIT-113: Added Plain Text Parameters plugin for CloudFormation
AkhtarAmir Aug 14, 2020
7c8616c
Added plugin and spec file for launch wizard security groups
AkhtarAmir Aug 14, 2020
de52e8a
Merge branch 'master' into feature/ec2-plugin-mark-launch-wizard-secu…
AkhtarAmir Aug 14, 2020
f3b72f6
Merge pull request #1 from AkhtarAmir/feature/ec2-plugin-mark-launch-…
AkhtarAmir Aug 14, 2020
d32cbac
Merge branch 'master' of https://github.com/AkhtarAmir/scans into fea…
AkhtarAmir Aug 14, 2020
3da6672
Refactored code in plaintextParameters plugin and spec file
AkhtarAmir Aug 14, 2020
928c712
Merge pull request #2 from AkhtarAmir/feature/SPLOIT-113
AkhtarAmir Aug 14, 2020
ce65325
SPLOIT-113: Updated custom settings
AkhtarAmir Aug 14, 2020
f3e3ab5
Merge pull request #3 from AkhtarAmir/feature/SPLOIT-113
AkhtarAmir Aug 14, 2020
e70b96a
Made PR requested changes
AkhtarAmir Aug 14, 2020
f62a1d5
SPLOIT-113: Added regex to check if NoEcho is enabled
AkhtarAmir Aug 14, 2020
865e0b6
Merge pull request #4 from AkhtarAmir/feature/SPLOIT-113
AkhtarAmir Aug 14, 2020
9745614
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Aug 15, 2020
1b80ac4
Accommodated PR changes
AkhtarAmir Aug 17, 2020
c0dc834
Fixed eslint issues
AkhtarAmir Aug 18, 2020
7d457bd
Update exports.js
AkhtarAmir Aug 18, 2020
8c2466c
Fixed eslint issues
AkhtarAmir Aug 18, 2020
ccb92ee
Update index.js
AkhtarAmir Aug 18, 2020
93c553d
Update index.js
AkhtarAmir Aug 18, 2020
cf21d1d
Added cloudformation in china and gov regions
AkhtarAmir Aug 18, 2020
aac8ece
Accomodated PR changes
AkhtarAmir Aug 18, 2020
7707dbd
Updated status in result of failure
AkhtarAmir Aug 18, 2020
a4ea92f
SPLOIT-113: Added Plain Text Parameters plugin for CloudFormation
AkhtarAmir Aug 14, 2020
8e5b6be
Added plugin and spec file for launch wizard security groups
AkhtarAmir Aug 14, 2020
a9afe44
Added vpcEndpointAcceptance plugin and spec file
AkhtarAmir Aug 13, 2020
0323a98
Refactored code in plaintextParameters plugin and spec file
AkhtarAmir Aug 14, 2020
aab9f79
SPLOIT-113: Updated custom settings
AkhtarAmir Aug 14, 2020
12d88c1
Made PR requested changes
AkhtarAmir Aug 14, 2020
7dd1a5b
SPLOIT-113: Added regex to check if NoEcho is enabled
AkhtarAmir Aug 14, 2020
c8a23c3
Accommodated PR changes
AkhtarAmir Aug 17, 2020
92821dd
Fixed eslint issues
AkhtarAmir Aug 18, 2020
e32accc
Update index.js
AkhtarAmir Aug 18, 2020
90094a2
Update index.js
AkhtarAmir Aug 18, 2020
c29ab07
Accomodated PR changes
AkhtarAmir Aug 18, 2020
49f1202
Updated status in result of failure
AkhtarAmir Aug 18, 2020
fa70d92
Updated master from upstream/master
AkhtarAmir Aug 21, 2020
357cd0b
SPLOIT-113: Added Plain Text Parameters plugin for CloudFormation
AkhtarAmir Aug 14, 2020
77ca002
Added plugin and spec file for launch wizard security groups
AkhtarAmir Aug 14, 2020
73172b8
Added vpcEndpointAcceptance plugin and spec file
AkhtarAmir Aug 13, 2020
7b448ff
Refactored code in plaintextParameters plugin and spec file
AkhtarAmir Aug 14, 2020
50d9d70
SPLOIT-113: Updated custom settings
AkhtarAmir Aug 14, 2020
46ff92c
Made PR requested changes
AkhtarAmir Aug 14, 2020
ec1e5ef
SPLOIT-113: Added regex to check if NoEcho is enabled
AkhtarAmir Aug 14, 2020
e89dd5e
Accommodated PR changes
AkhtarAmir Aug 17, 2020
4d7ee30
Fixed eslint issues
AkhtarAmir Aug 18, 2020
f5c9bf0
Update index.js
AkhtarAmir Aug 18, 2020
53e18b8
Update index.js
AkhtarAmir Aug 18, 2020
6ec73bc
Accomodated PR changes
AkhtarAmir Aug 18, 2020
2f55a11
Updated status in result of failure
AkhtarAmir Aug 18, 2020
0ba2fbf
SPLOIT-113: Added Plain Text Parameters plugin for CloudFormation
AkhtarAmir Aug 12, 2020
e9415b9
SPLOIT-113: Added Plain Text Parameters plugin for CloudFormation
AkhtarAmir Aug 14, 2020
8820775
Added plugin and spec file for launch wizard security groups
AkhtarAmir Aug 14, 2020
8e6b23b
Added vpcEndpointAcceptance plugin and spec file
AkhtarAmir Aug 13, 2020
82d8406
Refactored code in plaintextParameters plugin and spec file
AkhtarAmir Aug 14, 2020
b022a52
SPLOIT-113: Updated custom settings
AkhtarAmir Aug 14, 2020
d3ee380
Made PR requested changes
AkhtarAmir Aug 14, 2020
560d273
SPLOIT-113: Added regex to check if NoEcho is enabled
AkhtarAmir Aug 14, 2020
9195d32
Accommodated PR changes
AkhtarAmir Aug 17, 2020
0287cc5
Fixed eslint issues
AkhtarAmir Aug 18, 2020
1315ccd
Update exports.js
AkhtarAmir Aug 18, 2020
229461c
Update index.js
AkhtarAmir Aug 18, 2020
f5a3b8b
Update index.js
AkhtarAmir Aug 18, 2020
c574f76
Accomodated PR changes
AkhtarAmir Aug 18, 2020
1a4b495
Updated status in result of failure
AkhtarAmir Aug 18, 2020
a45a9f7
Merge branch 'master' of https://github.com/AkhtarAmir/scans into master
AkhtarAmir Aug 28, 2020
156d027
Removed unnecesary rebase changes
AkhtarAmir Aug 28, 2020
32ee6d9
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Sep 12, 2020
c687820
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Sep 22, 2020
29075e7
Merge branch 'master' of https://github.com/aquasecurity/cloudsploit …
AkhtarAmir Sep 24, 2020
c51edd1
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Sep 25, 2020
0768693
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Oct 16, 2020
2d04307
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Oct 20, 2020
c6b7eb1
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Nov 5, 2020
159f5dd
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Nov 21, 2020
d713e12
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Nov 26, 2020
b63a6d3
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Nov 30, 2020
472380f
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Nov 30, 2020
a95a46b
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Nov 30, 2020
f83f331
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Nov 30, 2020
55b0319
Merge branch 'master' of https://github.com/aquasecurity/cloudsploit
AkhtarAmir Dec 20, 2020
f627c6a
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Dec 22, 2020
6fe875d
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jan 21, 2021
d129f4b
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jan 21, 2021
c132394
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jan 22, 2021
68e9bfe
Merge branch 'master' of https://github.com/aquasecurity/cloudsploit
AkhtarAmir Jan 23, 2021
0cbc28f
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jan 23, 2021
2fa5e63
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jan 25, 2021
7319bca
Merge branch 'master' of https://github.com/AkhtarAmir/scans
AkhtarAmir Jan 25, 2021
4c73161
Added superlinter
AkhtarAmir Jan 26, 2021
6cda1ef
Added scans ci
AkhtarAmir Jan 27, 2021
072a98a
Updated Ci file
AkhtarAmir Jan 27, 2021
cb40648
Updated Node version in CI file
AkhtarAmir Jan 27, 2021
b0138cb
removed spech check command
AkhtarAmir Jan 27, 2021
239b8a6
Delete scan_ci.yml
AkhtarAmir Jan 27, 2021
63cd684
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jan 27, 2021
ab41137
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jan 27, 2021
f04d8d8
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jan 27, 2021
9c56577
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jan 28, 2021
8c3e0ef
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jan 29, 2021
32f8e04
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jan 29, 2021
2db8162
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jan 29, 2021
46cfe9d
Added spellcheck
AkhtarAmir Feb 1, 2021
5f0adec
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Feb 3, 2021
ea01ba2
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Mar 2, 2021
9f518b6
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Mar 5, 2021
0bf276d
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Mar 12, 2021
5271345
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Mar 14, 2021
da2417f
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Mar 23, 2021
ffe9864
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Mar 24, 2021
48d11fd
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Mar 26, 2021
2d04881
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Mar 29, 2021
c8edb8a
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Mar 29, 2021
fdaf02e
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Apr 1, 2021
c1373ac
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Apr 16, 2021
3b6aa18
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Apr 16, 2021
cd0b677
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Apr 16, 2021
459af26
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Apr 20, 2021
a130ed8
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Apr 20, 2021
239f7fd
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Apr 20, 2021
324c055
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Apr 22, 2021
627cf17
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Apr 23, 2021
219a8f4
Added Google BigQuery Dataset All Users Policy plugin and test cases
AkhtarAmir Apr 29, 2021
e66546b
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir May 4, 2021
b4df703
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir May 24, 2021
6c05290
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir May 25, 2021
c6322a0
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir May 26, 2021
18b1bac
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir May 26, 2021
80edb9e
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jun 7, 2021
8551067
HOTFIX/sqs-public-access: Logic will check policy condition as well
AkhtarAmir Jun 11, 2021
c5d78cb
Merge remote-tracking branch 'upstream/master' into master
AkhtarAmir Jun 17, 2021
eb865f1
Merge branch 'master' of https://github.com/AkhtarAmir/scans into fea…
AkhtarAmir Jun 17, 2021
b95b5b6
Merge branch 'master' into feature/akd-190
giorod3 Jun 30, 2021
106dbaf
Update plugins/google/bigquery/datasetAllUsersPolicy.js
giorod3 Jun 30, 2021
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
21 changes: 21 additions & 0 deletions collectors/google/collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ var calls = {
parent: true
}
},
datasets: {
list: {
api: 'bigquery',
version: 'v2',
location: null,
projectId: true
}
},
policies: {
list: {
api: 'dns',
Expand All @@ -196,6 +204,7 @@ var calls = {
api: 'pubsub',
version: 'v1',
parent: 'project'

}
}
};
Expand Down Expand Up @@ -258,6 +267,18 @@ var postcalls = {
filterKey: ['instance'],
filterValue: ['name'],
}
},
datasets: {
get: {
api: 'bigquery',
version: 'v2',
location: null,
reliesOnService: ['datasets'],
reliesOnCall: ['list'],
filterKey: ['datasetId'],
filterValue: ['id'],
projectId: true
}
}
};

Expand Down
4 changes: 3 additions & 1 deletion exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,9 @@ module.exports = {
'vpcNetworkLogging' : require(__dirname + '/plugins/google/logging/vpcNetworkLogging.js'),
'logSinksEnabled' : require(__dirname + '/plugins/google/logging/logSinksEnabled.js'),

'topicEncryption' : require(__dirname + '/plugins/google/pubsub/topicEncryption.js'),
'datasetAllUsersPolicy' : require(__dirname + '/plugins/google/bigquery/datasetAllUsersPolicy.js'),

'topicEncryption' : require(__dirname + '/plugins/google/pubsub/topicEncryption.js')
},
alibaba: {
'passwordMinLength' : require(__dirname + '/plugins/alibaba/ram/passwordMinLength.js'),
Expand Down
5 changes: 4 additions & 1 deletion helpers/google/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ var run = function(GoogleConfig, collection, settings, service, callObj, callKey
records = collection[callObj.reliesOnService[reliedService]][callObj.reliesOnCall[reliedService]][region].data;
async.eachLimit(records, 10, function(record, recordCb) {
for (var filter in callObj.filterKey) {
callObj.params[callObj.filterKey[filter]] = record[callObj.filterValue[filter]];
callObj.params[callObj.filterKey[filter]] = (record[callObj.filterValue[filter]] && record[callObj.filterValue[filter]].includes(':')) ?
record[callObj.filterValue[filter]].split(':')[1] :
record[callObj.filterValue[filter]];
options.version = callObj.version;
}
if (callObj.parent) {
Expand Down Expand Up @@ -359,6 +361,7 @@ var execute = function(LocalGoogleConfig, collection, service, callObj, callKey,
}
};
var parentParams;
if (callObj.projectId) callObj.params.projectId = LocalGoogleConfig.project;
if (callObj.nested && callObj.parent) {
parentParams = {auth: callObj.params.auth, parent: callObj.params.parent};
executor['projects']['locations'][service][callKey](parentParams, LocalGoogleConfig, executorCb);
Expand Down
1 change: 1 addition & 0 deletions helpers/google/regions.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ module.exports = {
keys: ['global'],
sinks: ['global'],
users: ['global'],
datasets: ['global'],
policies: ['global'],
topics: ['global']
};
69 changes: 69 additions & 0 deletions plugins/google/bigquery/datasetAllUsersPolicy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
var async = require('async');
var helpers = require('../../../helpers/google');

module.exports = {
title: 'Dataset All Users Policy',
category: 'BigQuery',
description: 'Ensure that BigQuery datasets do not allow public read, write or delete access.',
more_info: 'Granting permissions to allUsers or allAuthenticatedUsers allows anyone to access the dataset. Such access might not be desirable if sensitive data is being stored in the dataset.',
link: 'https://cloud.google.com/bigquery/docs/dataset-access-controls',
recommended_action: 'Ensure that each dataset is configured so that no member is set to allUsers or allAuthenticatedUsers.',
apis: ['datasets:list', 'datasets:get'],

run: function(cache, settings, callback) {
var results = [];
var source = {};
var regions = helpers.regions();

async.each(regions.datasets, function(region, rcb){
let datasetsGet = helpers.addSource(cache, source,
['datasets', 'get', region]);

if (!datasetsGet) return rcb();

if (datasetsGet.err || !datasetsGet.data) {
helpers.addResult(results, 3, 'Unable to query BigQuery datasets: ' + helpers.addError(datasetsGet), region);
return rcb();
}

if (!datasetsGet.data.length) {
helpers.addResult(results, 0, 'No BigQuery datasets found', region);
return rcb();
}

async.each(datasetsGet.data, (dataset, dcb) => {
if (!dataset.id) return dcb();

var permissionStr = [];
if (dataset.access) {
for (let rolePermission of dataset.access) {
for (let property in rolePermission) {
if (!rolePermission['role']) continue;
giorod3 marked this conversation as resolved.
Show resolved Hide resolved

if (rolePermission[property] &&
(rolePermission[property].toLowerCase() == 'allusers' || rolePermission[property].toLowerCase() == 'allauthenticatedusers')) {
permissionStr.push(`${rolePermission['role']} access to ${rolePermission[property]}`);
}
}
}

if (permissionStr.length) {
helpers.addResult(results, 2,
`BigQuery dataset provides ${permissionStr.join(',')}`, region, dataset.id);
} else {
helpers.addResult(results, 0,
'BigQuery dataset does not provide public access', region, dataset.id);
}
} else {
helpers.addResult(results, 0,
'BigQuery dataset does not provide public access', region, dataset.id);
}
});

rcb();
}, function(){
// Global checking goes here
callback(null, results, source);
});
}
}
120 changes: 120 additions & 0 deletions plugins/google/bigquery/datasetAllUsersPolicy.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
var assert = require('assert');
var expect = require('chai').expect;
var plugin = require('./datasetAllUsersPolicy');

const datasetGet = [
{
"kind": "bigquery#dataset",
"id": "aqua-dev-cloudsploit:aqua_ds",
"selfLink": "https://www.googleapis.com/bigquery/v2/projects/aqua-dev-cloudsploit/datasets/aqua_ds",
"datasetReference": { "datasetId": "aqua_ds", "projectId": "aqua-dev-cloudploit" },
"access": [
{ "role": "WRITER", "specialGroup": "projectWriters" },
{ "role": "OWNER", "specialGroup": "projectOwners" },
{ "role": "READER", "specialGroup": "projectReaders" }
],
"creationTime": "1619622395743",
"lastModifiedTime": "1619699668544",
"location": "US",
"type": "DEFAULT"
},
{
"kind": "bigquery#dataset",
"id": "aqua-dev-cloudsploit:aqua_ds",
"selfLink": "https://www.googleapis.com/bigquery/v2/projects/aqua-dev-cloudsploit/datasets/aqua_ds",
"datasetReference": { "datasetId": "aqua_ds", "projectId": "aqua-dev-cloudploit" },
"access": [
{ "role": "WRITER", "iamMember": "allUsers" },
{ "role": "WRITER", "specialGroup": "projectWriters" },
{ "role": "OWNER", "specialGroup": "projectOwners" },
{ "role": "READER", "specialGroup": "allAuthenticatedUsers" },
{ "role": "READER", "specialGroup": "projectReaders" }
],
"creationTime": "1619622395743",
"lastModifiedTime": "1619699668544",
"location": "US",
"type": "DEFAULT"
}
];

const createCache = (err, data) => {
return {
datasets: {
get: {
'global': {
err: err,
data: data
}
}
}
}
};

describe('datasetAllUsersPolicy', function () {
describe('run', function () {
it('should give unknown result if unable to query BigQuery datasets', 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 BigQuery datasets');
expect(results[0].region).to.equal('global');
done()
};

const cache = createCache(
['error'],
null,
);

plugin.run(cache, {}, callback);
});
it('should give passing result if no datasets found', 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('No BigQuery datasets found');
expect(results[0].region).to.equal('global');
done()
};

const cache = createCache(
null,
[],
);

plugin.run(cache, {}, callback);
});
it('should give passing result if BigQuery dataset does not provide public access', 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('BigQuery dataset does not provide public access');
expect(results[0].region).to.equal('global');
done()
};

const cache = createCache(
null,
[datasetGet[0]]
);

plugin.run(cache, {}, callback);
});
it('should give failing result if BigQuery dataset provides public access', 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('BigQuery dataset provides');
expect(results[0].region).to.equal('global');
done()
};

const cache = createCache(
null,
[datasetGet[1]]
);

plugin.run(cache, {}, callback);
})
})
});