Top Level Namespace

Defined Under Namespace

Modules: AutoFix, Formatter, Rules, Sentinel Classes: CloneClient, Finding, GitHubClient, LocalClient, MockShaResolver, RuleEngine, Scanner, ShaResolver, Workflow

Instance Method Summary collapse

Instance Method Details

#resolve_token(options) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/cli/scan.rb', line 63

def resolve_token(options)
    return options[:token] if options[:token]
    return ENV["GITHUB_TOKEN"] if ENV["GITHUB_TOKEN"]

    gh_path = `which gh 2>/dev/null`.strip
    if !gh_path.empty? && system("gh", "auth", "status", [:out, :err] => File::NULL)
        token = `gh auth token 2>/dev/null`.strip
        return token unless token.empty?
    end

    nil
end