GithubHelp home page GithubHelp logo

aquasecurity / saas-api-samples Goto Github PK

View Code? Open in Web Editor NEW
13.0 5.0 22.0 54 KB

Sample code snippets for consuming the CloudSploit API

JavaScript 50.97% Python 37.48% HCL 9.65% Shell 0.11% Ruby 1.79%

saas-api-samples's Introduction

SaaS API Samples for Aqua

Table of Contents

Python samples

cd sample-python

Javascript samples

cd sample-js

Ruby samples

cd sample-ruby

Install gems

bundle

Add API key and secret

Create .env file for local environment variables.

cp sample.env .env

Edit .env.

vi .env

Update API_KEY and API_SECRET values.

API_KEY=api-key-123
API_SECRET=api-secret-456

Run example

The tests.rb example will query all current plugins from the API endpoint and return a JSON object.

ruby tests.rb

saas-api-samples's People

Contributors

citizenjosh avatar dependabot[bot] avatar dipsubha06 avatar giorod3 avatar joshlarsen avatar krol3 avatar matthewdfuller avatar thisisalim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

saas-api-samples's Issues

Internal server error with valid key, secret, and scan id

For either scan_details.py or scan_details_p3.py if I change the key, secret, and scan id, I get...

{"message": "Internal server error"}

and the headers are...

{'Content-Type': 'application/json', 'Content-Length': '36', 'Connection': 'keep-alive', 'Date': 'Wed, 29 May 2019 18:12:35 GMT', 'x-amzn-RequestId': '54a6bce2-823d-11e9-bfde-51de89216955', 'x-amz-apigw-id': 'adS-wGp3IAMFvRg=', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 b4462bd98dd9186cca8c54d37f70d629.cloudfront.net (CloudFront)', 'X-Amz-Cf-Id': 'rQlaKKypuiM46Kp5uZacMwGqDUXp3mjmMYj2NqTTWsoPzPlmZ_0ApQ=='}

Start Date and End Date Parameters

My goal is to pull data from the '/v2/scans' endpoint for the past 30 days but the 'start_date' and 'end_date' parameters only give me data for the current and previous day (2 days). Any suggestions on how I could work around this?

["This endpoint is not accessible via API"]}

Hi,

I'm currently trying to use the API to pull down the compliance reports on some of our scans. I've followed the documentation and confirmed the pre-reqs and also verified the key has global admin permissions currently. I also used one of the Python scripts in this library and modified it slightly to do this. However when posting I'm getting a Error 403.

Is there any other requirements I should check for? GET commands seem to work fine and I can gather info that way but I'm looking to download the PDF reports.

More info below:

{"status":403,"id":"f80b81bf-ed81-4331-bc3f-38ffb7a9ac7b","code":1,"message":"Access denied","errors":["This endpoint is not accessible via API"]}

PYTHON Script:

import sys
import json
import time
import hmac
import base64
import hashlib
import requests

Obtain a CloudSploit API key and secret from the dashboard

api_key = "Key here"
secret = "Secret"

base_url = "https://api.cloudsploit.com"

method = 'POST'
path = "/v2/pdfs"

body = {
"report": "scan",
"scan_id": 123
}
body_str = json.dumps(body, separators=(',', ':'))
timestamp = str(int(time.time() * 1000))
endpoint = base_url + path

string = timestamp + method + path + body_str
secret_bytes= bytes(secret , 'latin-1')
string_bytes = bytes(string, 'latin-1')

signature = hmac.new(secret_bytes, msg=string_bytes, digestmod=hashlib.sha256).hexdigest()

hdr = {
"Accept": "application/json",
"X-API-Key": api_key,
"X-Signature": signature,
"X-Timestamp": timestamp,
"content-type": "application/json"
}

r=requests.post(endpoint, headers=hdr, data=body_str)
print (r.text)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.