Class: Caido::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/caido/instance.rb,
lib/caido/helpers/export.rb,
lib/caido/helpers/replay.rb,
lib/caido/helpers/request.rb,
lib/caido/helpers/runtime.rb,
lib/caido/helpers/sitemap.rb,
lib/caido/helpers/_example.rb,
lib/caido/helpers/automate.rb,
lib/caido/helpers/response.rb,
lib/caido/helpers/workflow.rb,
lib/caido/helpers/workspace.rb,
lib/caido/helpers/hosted_file.rb

Overview

Instance class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Instance

Returns a new instance of Instance.



14
15
16
17
18
# File 'lib/caido/instance.rb', line 14

def initialize(*args)
  set_defaults
  process_arguments(args)
  auth_from_env
end

Instance Attribute Details

#authorizationObject (readonly)

Returns the value of attribute authorization.



12
13
14
# File 'lib/caido/instance.rb', line 12

def authorization
  @authorization
end

#graphql_urlObject (readonly)

Returns the value of attribute graphql_url.



12
13
14
# File 'lib/caido/instance.rb', line 12

def graphql_url
  @graphql_url
end

Instance Method Details

#automate_session(id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/caido/helpers/automate.rb', line 6

def automate_session(id)
  query("query{
    automateSession(id: \"#{id}\"){
      id
      name
      raw
      createdAt
    }
  }")['automateSession']
end

#automate_sessionsObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/caido/helpers/automate.rb', line 17

def automate_sessions
  query('query{
    automateSessions{
      nodes{
        id
        name
        raw
        createdAt
      }
    }
  }')['automateSessions']
end

#backupsObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/caido/helpers/workspace.rb', line 17

def backups
  query('query{
    backups{
      id
      name
      status
      updatedAt
      createdAt
      path
      size
      downloadUri
    }
  }')['backups']
end

#example_helperObject



6
7
8
# File 'lib/caido/helpers/_example.rb', line 6

def example_helper
  'test'
end

#export(id) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/caido/helpers/export.rb', line 22

def export(id)
  query("query{
    dataExport(id: \"#{id}\"){
      id
      format
      name
      status
      error
      createdAt
      path
      size
      downloadUri
    }
  }")['dataExport']
end

#exportsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/caido/helpers/export.rb', line 6

def exports
  query('query{
    dataExports{
      id
      format
      name
      status
      error
      createdAt
      path
      size
      downloadUri
    }
  }')['dataExports']
end

#hosted_filesObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/caido/helpers/hosted_file.rb', line 6

def hosted_files
  query('query {
    hostedFiles {
      id
      name
      createdAt
      updatedAt
      path
      size
    }
  }')['hostedFiles']
end

#platformObject



10
11
12
# File 'lib/caido/helpers/runtime.rb', line 10

def platform
  query('{runtime{platform}}')['runtime']['platform']
end

#projectsObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/caido/helpers/workspace.rb', line 6

def projects
  query('query {
    projects{
      id
      name
      version
      updatedAt
    }
  }')['projects']
end

#replay_collectionsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/caido/helpers/replay.rb', line 6

def replay_collections
  query('query {
    replaySessionCollections{
      nodes{
        name
        sessions{
          name
          id
        }
      }
    }
  }')['replaySessionCollections']['nodes']
end

#replay_session(id) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/caido/helpers/replay.rb', line 20

def replay_session(id)
  query("query{
    replaySession(id: \"#{id}\"){
      name
      activeEntry{
        request{
        host
        path
        method
        query
        raw
        isTls
        fileExtension
        source
        port

        }
      }
    }
  }")['replaySession']
end

#replay_sessionsObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/caido/helpers/replay.rb', line 42

def replay_sessions
  sessions_data = []
  collections = query('query {
    replaySessionCollections{
      nodes{
        name
        sessions{
          name
          id
        }
      }
    }
  }')['replaySessionCollections']['nodes']

  collections.each do |collection|
    next unless collection

    sessions = collection['sessions']

    sessions.each do |session|
      next unless session

      sessions_data << query("query{
          replaySession(id: \"#{session['id']}\"){
            name
            activeEntry{
              request{
              host
              path
              method
              query
              raw
              isTls
              fileExtension
              source
              port

              }
            }
          }
        }")['replaySession']
    end
  end

  sessions_data
end

#request(id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/caido/helpers/request.rb', line 6

def request(id)
  query("query{
    request(id:\"#{id}\"){
        id
        host
        method
        query
        length
        port
        isTls
        fileExtension
        source
        alteration
        edited
        createdAt
        raw
        response{
          id
          statusCode
          length
          roundtripTime
          edited
          raw
        }
    }
  }")['request']
end

#response(id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/caido/helpers/response.rb', line 6

def response(id)
  query("query{
    response(id:\"#{id}\"){
      id
      statusCode
      length
      roundtripTime
      edited
      raw
    }
  }")['response']
end

#sitemap_entiry(id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/caido/helpers/sitemap.rb', line 6

def sitemap_entiry(id)
  query("query{
    sitemapEntry(id: \"#{id}\"){
      id
      label
      kind
      parentId
      request{
        id
        host
        method
        query
        length
        port
        isTls
        fileExtension
        source
        alteration
        edited
        createdAt
        raw
        response{
          id
          statusCode
          length
          roundtripTime
          edited
          raw
        }
      }
    }
  }")['sitemapEntry']
end

#versionObject



6
7
8
# File 'lib/caido/helpers/runtime.rb', line 6

def version
  query('{runtime{version}}')['runtime']['version']
end

#workflow(id) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/caido/helpers/workflow.rb', line 21

def workflow(id)
  query("query{
    workflow(id: \"#{id}\"){
      id
      name
      kind
      enabled
      global
      definition
      createdAt
      updatedAt
    }
  }")['workflow']
end

#workflowsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/caido/helpers/workflow.rb', line 6

def workflows
  query('query{
    workflows{
      id
      name
      kind
      enabled
      global
      definition
      createdAt
      updatedAt
    }
  }')['workflows']
end