Skip to content

Latest commit

 

History

History
39 lines (34 loc) · 2.22 KB

github.md

File metadata and controls

39 lines (34 loc) · 2.22 KB

Table of Contents generated with DocToc

Github Configuration

Follow these steps to analyze Github repos and other objects with Cartography.

  1. Prepare your Github credentials.
    1. Github ingest supports multiple endpoints, such as a public instance and an enterprise instance by taking a base64-encoded config object structured as
      {
      "organization": [
          {
              "token": "faketoken",
              "url": "https://api.github.com/graphql",
              "name": "fakeorg"
          },
          {
              "token": "stillfake",
              "url": "https://github.example.com/api/graphql",
              "name": "fakeorg"
          }]
      }
    2. For each Github instance you want to ingest, generate an API token as documented in the API reference
    3. Create your auth config as shown above using the token obtained in the previous step. If you are configuring only the public Github instance, you can just use the first config block and delete the second. The name field is for the organization name you want to ingest.
    4. Base64 encode the auth object and populate an environment variable with the result. For example, you could encode the above sample in Python using
      import json
      import base64
      str = json.dumps({"organization":[{"token":"faketoken","url":"https://api.github.com/graphql","name":"fakeorg"},{"token":"stillfake","url":"https://github.example.com/api/graphql","name":"fakeorg"}]})
      base64.b64encode(str.encode())
      and the resulting environment variable would be eyJvcmdhbml6YXRpb24iOiBbeyJ0b2tlbiI6ICJmYWtldG9rZW4iLCAidXJsIjogImh0dHBzOi8vYXBpLmdpdGh1Yi5jb20vZ3JhcGhxbCIsICJuYW1lIjogImZha2VvcmcifSwgeyJ0b2tlbiI6ICJzdGlsbGZha2UiLCAidXJsIjogImh0dHBzOi8vZ2l0aHViLmV4YW1wbGUuY29tL2FwaS9ncmFwaHFsIiwgIm5hbWUiOiAiZmFrZW9yZyJ9XX0=