Comments (6)
I cannot replicate this, can you give further details? maybe some example code?
from pysecuritycenter.
Here's my code.
#!/usr/bin/env/python
from boto import ec2
import getpass
from securitycenter import SecurityCenter5
def get_AWS_instances(AWS_Access_Key,AWS_Secret_Key):
AWS_ACCESS_KEY_ID=AWS_Access_Key
AWS_SECRET_ACCESS_KEY=AWS_Secret_Key
ip_list = []
noscan = 0
ec2conn = ec2.connection.EC2Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
reservations = ec2conn.get_all_instances()
instances = [i for r in reservations for i in r.instances]
for i in instances:
size = str(i.instance_type)
current_state = str(i.state)
if 'running' in current_state:
if '.micro' in size:
noscan += 1
elif '.small' in size:
noscan += 1
else:
ip_list.append(str(i.private_ip_address))
print "Not including " + str(noscan) + " instances in scan profile."
return ip_list
def add_asset(sc, asset_name, asset_ips, asset_description):
sc.post('asset', json={
'context': '',
'createdTime': 0,
'modifiedTime': 0,
'status': -1,
'type': 'static',
'name': asset_name,
'definedIPs': asset_ips,
'description': asset_description,
'tags': "",
})
print '** Imported %s using %s' % (asset_name, asset_ips)
def update_asset(sc, asset_id, asset_ips_updates):
# Example Use:
# sc.patch('asset/45', json={'definedIPs':'10.0.0.1,10.0.0.2,10.0.0.3'})
sc.patch('asset/%s' % asset_id, json={'definedIPs': ','.join(asset_ips_updates)})
print "Asset : %s updated with %s IP Addresses : %s" % (asset_id, str(len(asset_ips_updates)), ','.join(asset_ips_updates))
if __name__ == '__main__':
# Get the needed login info from the user...
host = raw_input('SecurityCenter Server : ')
scname = raw_input('SecurityCenter Username : ')
scpass = getpass.getpass('SecurityCenter Password : ')
AWS_Access_Key = getpass.getpass('AWS_ACCESS_KEY_ID : ')
AWS_Secret_Key = getpass.getpass('AWS_SECRET_ACCESS_KEY : ')
# Get all running instances, minus micros and smalls, from AWS account.
available_ips = get_AWS_instances(AWS_Access_Key,AWS_Secret_Key)
# Log into Security Center
sc = SecurityCenter5(host)
sc.login(scname,scpass)
# Update SC5 asset record
update_asset(sc, str(45), available_ips)
from pysecuritycenter.
I updated my pysecuritycenter to the latest version and still getting the following error. Odd thing is, this above code works for one account and will not work for my 2 other AWS accounts.
Traceback (most recent call last):
File "AWS_to_SC5.py", line 76, in
sc.login(scname,scpass)
File "/Library/Python/2.7/site-packages/securitycenter/sc5.py", line 45, in login
self._token = resp.json()['response']['token']
KeyError: 'token'
from pysecuritycenter.
is the login information valid?
from pysecuritycenter.
Yes. Found the issue. We enabled session management with a limit of 1 session per each user account. The account being used for the update was logged in when the script kicked off. I was able to update all of my asset groups.
from pysecuritycenter.
Glad to hear that the issue was external to the API ;) I'll close the issue now.
from pysecuritycenter.
Related Issues (20)
- Trying to update existing assets HOT 2
- Getting AttributError and ImportError while running code HOT 4
- sc5.py line 105 HOT 1
- header value wrong type HOT 4
- need some guidance HOT 2
- Trying to install
- Release Token HOT 1
- downloader.py HOT 2
- An advert for Tenable.io SDK HOT 1
- from securitycenter import SecurityCenter5 fails for py3 HOT 9
- report_downloader.py args issue HOT 1
- Data Cleanup HOT 3
- downloader.py issue HOT 1
- ConnectionError with Python 3 HOT 1
- Release v3.0.3? HOT 1
- sc.upload() not returning filename HOT 3
- ERROR - 'module' object has no attribute 'SecurityCenter5'
- Having an issue pulling data from vulndetails HOT 1
- API documentation changed on Tenable's site HOT 1
- SecurityCenter 5 - sc.analysis method - design issue - analysis/download HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysecuritycenter.