Sha256: e13cd8a0b72b46cc40a22499458dd22aebb6aa0cffba49c40b4ea030e17545de

Contents?: true

Size: 867 Bytes

Versions: 1

Compression:

Stored size: 867 Bytes

Contents

require 'async'
require 'vaas/client_credentials_grant_authenticator'
require 'vaas/vaas_main'

CLIENT_ID = ENV.fetch('CLIENT_ID')
CLIENT_SECRET = ENV.fetch('CLIENT_SECRET')
PATH = ENV.fetch('PATH')

def main
  authenticator = VAAS::ClientCredentialsGrantAuthenticator.new(
    CLIENT_ID,
    CLIENT_SECRET,
    "https://keycloak-vaas.gdatasecurity.de/realms/vaas/protocol/openid-connect/token"
  )

  # create a vaas object and get a token to authenticate
  vaas = VAAS::VaasMain.new
  token = authenticator.get_token

  Async do
    # wait to connect and authenticate
    Async { vaas.connect(token) }.wait

    # simple method to get the verdict of a file
    verdict = vaas.for_file(PATH)

    puts "Verdict #{verdict.sha256} is detected as #{verdict.verdict}"

  ensure
    vaas.close
  end
end

if __FILE__  == $0
  main
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vaas-1.0.1 examples/simple_example.rb