Esempio n. 1
0
def setup_authentication(jira_password, region, pk_passphrase=None):
    print(
        "The access key for SnowAlert's Snowflake account can have a passphrase, if you wish."
    )

    if pk_passphrase is None:
        pk_passphrase = getpass(
            "RSA key passphrase [blank for none, '.' for random]: ")

    if pk_passphrase == '.':
        pk_passphrase = b64encode(urandom(18)).decode('utf-8')
        print("Generated random passphrase.")

    private_key, public_key = genrsa(pk_passphrase)

    if pk_passphrase:
        print(
            "\nAdditionally, you may use Amazon Web Services for encryption and audit."
        )
        kms = boto3.client('kms', region_name=region)
        while True:
            try:
                pk_passphrase, jira_password = do_kms_encrypt(
                    kms, pk_passphrase, jira_password)
                break

            except KeyboardInterrupt:
                log.fatal("User ended installation")

            except Exception as e:
                print(f"error {e!r}, trying.")

    rsa_public_key = re.sub(r'---.*---\n', '', public_key.decode('utf-8'))

    return private_key, pk_passphrase, jira_password, rsa_public_key
Esempio n. 2
0
def main():
    reqenv = {'AGARI_TOKEN', 'AGARI_SECRET', 'AGARI_TABLE'}
    missingenv = reqenv - set(environ)
    if missingenv:
        log.fatal(f"missing env vars: {missingenv}")

    for url in URLS:
        process_endpoint(url)
Esempio n. 3
0
 def attempt(message="doing", todo=None):
     print(f"{message}", end="..", flush=True)
     try:
         if type(todo) is str:
             retval = ctx.cursor().execute(todo).fetchall()
             print('.', end='', flush=True)
         if type(todo) is list:
             retval = [ctx.cursor().execute(query) for query in todo if (True, print('.', end='', flush=True))]
         elif callable(todo):
             retval = todo()
     except Exception as e:
         log.fatal("failed", e)
     print(" ✓")
     return retval
Esempio n. 4
0
def main():
    reqenv = {'ZENGRC_ID', 'ZENGRC_SECRET', 'ZENGRC_URL', 'ZENGRC_TABLE'}
    missingenv = reqenv - set(environ)
    if missingenv:
        log.fatal(f"missing env vars: {missingenv}")

    print("starting")

    last_time = list(db.fetch(GET_FRESH_ENTRIES_QUERY))

    if len(last_time) == 0:
        for e in ENDPOINTS:
            process_endpoint(e)
    else:
        log.info("Not time to ingest ZenGRC data")
Esempio n. 5
0
def main():
    url = OKTA_URL
    log.info("starting loop")
    timestamp = get_timestamp()
    while 1:
        log.info(f"url is ${url}")
        try:
            r = requests.get(url=url, headers=HEADERS, params=timestamp)
            if str(r) != '<Response [200]>':
                log.fatal('OKTA REQUEST FAILED: ', r.text)
            process_logs(json.loads(r.text))
            if len(r.text) == 2:
                break
            url = r.headers['Link'].split(', ')[1].split(';')[0][1:-1]
        except Exception as e:
            log.error("Error with Okta logs: ", e)

    alooma_pysdk.terminate()