-
Notifications
You must be signed in to change notification settings - Fork 668
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2023 from aquasecurity/bundles_sync/29_05
syncing with saas
- Loading branch information
Showing
24 changed files
with
395 additions
and
141 deletions.
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,52 @@ | ||
var async = require('async'); | ||
var helpers = require('../../../helpers/aws'); | ||
|
||
module.exports = { | ||
title: 'AWS Bedrock In Use', | ||
category: 'AI & ML', | ||
domain: 'Machine Learning', | ||
severity: 'Low', | ||
description: 'Ensures that AWS Bedrock service is in use within your AWS account.', | ||
more_info: 'AWS Bedrock provides access to high-performing foundation models from leading AI startups and Amazon through a unified API, enabling easy experimentation, customization, and deployment of generative AI applications with robust security and privacy features.', | ||
link: 'https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-bedrock.html', | ||
recommended_action: 'Use Bedrock service to utilize top foundation models with strong security and customization.', | ||
apis: ['Bedrock:listCustomModels'], | ||
realtime_triggers: ['bedrock:DeleteCustomModel'], | ||
|
||
run: function(cache, settings, callback) { | ||
var results = []; | ||
var source = {}; | ||
var regions = helpers.regions(settings); | ||
|
||
async.each(regions.bedrock, function(region, rcb){ | ||
var listCustomModels = helpers.addSource(cache, source, | ||
['bedrock', 'listCustomModels', region]); | ||
|
||
if (!listCustomModels) return rcb(); | ||
|
||
if (listCustomModels.err && listCustomModels.err.message.includes('Unknown operation')) { | ||
helpers.addResult(results, 0, | ||
'Custom model service is not available in this region', region); | ||
return rcb(); | ||
} | ||
|
||
if (listCustomModels.err || !listCustomModels.data) { | ||
helpers.addResult(results, 3, | ||
`Unable to query for Bedrock custom model list: ${helpers.addError(listCustomModels)}`, region); | ||
return rcb(); | ||
} | ||
|
||
if (!listCustomModels.data.length) { | ||
helpers.addResult(results, 2, 'Bedrock service is not in use', region); | ||
return rcb(); | ||
} else { | ||
helpers.addResult(results, 0, 'Bedrock service is in use', region); | ||
return rcb(); | ||
|
||
} | ||
|
||
}, function(){ | ||
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,73 @@ | ||
var expect = require('chai').expect; | ||
const bedrockInUse = require('./bedrockInUse'); | ||
|
||
const listCustomModels = [ | ||
{ | ||
"modelArn": "arn:aws:bedrock:us-east-1:11223344:custom-model/amazon.titan-text-lite-v1:0:4k/2ytyyx8nid0h", | ||
"modelName": "model2", | ||
"creationTime": "2023-11-29T10:45:43.056000+00:00", | ||
"baseModelArn": "arn:aws:bedrock:us-east-1::foundation-model/amazon.titan-text-lite-v1:0:4k", | ||
"baseModelName": "" | ||
}, | ||
{ | ||
"modelArn": "arn:aws:bedrock:us-east-1:11223344:custom-model/amazon.titan-text-lite-v1:0:4k/vjqsydtdhkpz", | ||
"modelName": "testmodel2", | ||
"creationTime": "2023-11-28T11:29:18.655000+00:00", | ||
"baseModelArn": "arn:aws:bedrock:us-east-1::foundation-model/amazon.titan-text-lite-v1:0:4k", | ||
"baseModelName": "" | ||
} | ||
]; | ||
|
||
|
||
const createCache = (listModels) => { | ||
return { | ||
bedrock: { | ||
listCustomModels: { | ||
'us-east-1': { | ||
err: null, | ||
data: listModels | ||
} | ||
}, | ||
} | ||
}; | ||
}; | ||
|
||
|
||
describe('bedrockInUse', function () { | ||
describe('run', function () { | ||
it('should PASS if Bedrock service is in use', function (done) { | ||
const cache = createCache([listCustomModels[0]]); | ||
bedrockInUse.run(cache, {}, (err, results) => { | ||
expect(results.length).to.equal(1); | ||
expect(results[0].status).to.equal(0); | ||
expect(results[0].region).to.equal('us-east-1'); | ||
expect(results[0].message).to.include('Bedrock service is in use') | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should FAIL if Bedrock service is not in use', function (done) { | ||
const cache = createCache([]); | ||
bedrockInUse.run(cache, {}, (err, results) => { | ||
expect(results.length).to.equal(1); | ||
expect(results[0].status).to.equal(2); | ||
expect(results[0].region).to.equal('us-east-1'); | ||
expect(results[0].message).to.include('Bedrock service is not in use') | ||
done(); | ||
}); | ||
}); | ||
|
||
|
||
it('should UNKNOWN if unable to query Bedrock custom model', function (done) { | ||
const cache = createCache(null, null); | ||
bedrockInUse.run(cache, {}, (err, results) => { | ||
expect(results.length).to.equal(1); | ||
expect(results[0].status).to.equal(3); | ||
expect(results[0].region).to.equal('us-east-1'); | ||
expect(results[0].message).to.include('Unable to query for Bedrock custom model list') | ||
done(); | ||
}); | ||
}); | ||
|
||
}); | ||
}); |
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
Oops, something went wrong.