Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
- name: Run linters
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v8
with:
version: latest
version: v2.1.6
args: --timeout=3m
go-test:
strategy:
Expand Down
204 changes: 112 additions & 92 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,96 +1,116 @@
#AUTO GENERATED CODE. UPDATE THE CONFIG IN BATON-TEMPLATE FIRST
linters-settings:
exhaustive:
default-signifies-exhaustive: true
gocritic:
enabled-checks:
- ruleguard
# The list of supported checkers can be find in https://go-critic.github.io/overview.
settings:
underef:
# Whether to skip (*x).method() calls where x is a pointer receiver.
skipRecvDeref: false
ruleguard:
rules: "${configDir}/tools/rules.go"
govet:
enable-all: true
disable:
- fieldalignment # too strict
- shadow # complains too much about shadowing errors. All research points to this being fine.
nakedret:
max-func-lines: 0
nolintlint:
allow-no-explanation: [forbidigo, tracecheck, gomnd, gochecknoinits, makezero]
require-explanation: true
require-specific: true
revive:
ignore-generated-header: true
severity: error
rules:
- name: atomic
- name: line-length-limit
arguments: [200]
# These are functions that we use without checking the errors often. Most of these can't return an error even
# though they implement an interface that can.
- name: unhandled-error
arguments:
- fmt.Printf
- fmt.Println
- fmt.Fprint
- fmt.Fprintf
- fmt.Fprintln
- os.Stderr.Sync
- sb.WriteString
- buf.WriteString
- hasher.Write
- os.Setenv
- os.RemoveAll
- name: var-naming
arguments: [["ID", "URL", "HTTP", "API"], []]
tenv:
all: true
version: "2"
linters:
disable-all: true
default: none
enable:
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
- gosimple # Linter for Go source code that specializes in simplifying a code
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- ineffassign # Detects when assignments to existing variables are not used
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
- unused # Checks Go code for unused constants, variables, functions and types
- asasalint # Check for pass []any as any in variadic func(...any)
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
- bidichk # Checks for dangerous unicode character sequences
- bodyclose # checks whether HTTP response body is closed successfully
- durationcheck # check for two durations multiplied together
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
- exhaustive # check exhaustiveness of enum switch statements
- forbidigo # Forbids identifiers
- gochecknoinits # Checks that no init functions are present in Go code
- goconst # Finds repeated strings that could be replaced by a constant
- gocritic # Provides diagnostics that check for bugs, performance and style issues.
- godot # Check if comments end in a period
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt.
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
- goprintffuncname # Checks that printf-like functions are named with f at the end
- gosec # Inspects source code for security problems
- nakedret # Finds naked returns in functions greater than a specified function length
- nilerr # Finds the code that returns nil even if it checks that the error is not nil.
- noctx # noctx finds sending http request without context.Context
- nolintlint # Reports ill-formed or insufficient nolint directives
- nonamedreturns # Reports all named returns
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.
- predeclared # find code that shadows one of Go's predeclared identifiers
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
- unconvert # Remove unnecessary type conversions
- usestdlibvars # detect the possibility to use variables/constants from the Go standard library
- whitespace # Tool for detection of leading and trailing whitespace
- asasalint
- asciicheck
- bidichk
- bodyclose
- durationcheck
- errcheck
- errorlint
- exhaustive
- forbidigo
- gochecknoinits
- goconst
- gocritic
- godot
- gomoddirectives
- goprintffuncname
- gosec
- govet
- ineffassign
- nakedret
- nilerr
- noctx
- nolintlint
- nonamedreturns
- nosprintfhostport
- predeclared
- revive
- staticcheck
- tparallel
- unconvert
- unused
- usestdlibvars
- whitespace
settings:
exhaustive:
default-signifies-exhaustive: true
gocritic:
enabled-checks:
- ruleguard
settings:
ruleguard:
rules: ${base-path}/tools/rules.go
underef:
skipRecvDeref: false
govet:
disable:
- fieldalignment
- shadow
enable-all: true
nakedret:
max-func-lines: 0
nolintlint:
require-explanation: true
require-specific: true
allow-no-explanation:
- forbidigo
- tracecheck
- gomnd
- gochecknoinits
- makezero
revive:
severity: error
rules:
- name: atomic
- name: line-length-limit
arguments:
- 200
- name: unhandled-error
arguments:
- fmt.Printf
- fmt.Println
- fmt.Fprint
- fmt.Fprintf
- fmt.Fprintln
- os.Stderr.Sync
- sb.WriteString
- buf.WriteString
- hasher.Write
- os.Setenv
- os.RemoveAll
- name: var-naming
arguments:
- - ID
- URL
- HTTP
- API
- []
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- godot
source: (TODO)
paths:
- third_party$
- builtin$
- examples$
issues:
max-same-issues: 50
exclude-rules:
# Don't require TODO comments to end in a period
- source: "(TODO)"
linters: [godot]
formatters:
enable:
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ add-dep:
.PHONY: lint
lint:
golangci-lint run

35 changes: 23 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ baton resources

By default, `baton-github` will sync information from any organizations that the provided credential has Administrator permissions on. You can specify exactly which organizations you would like to sync using the `--orgs` flag.

# Sync Secrets
in order to sync secrets, you must use a token created using a github app installed into your organization, more info here:
- [docs](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-user-access-token-for-a-github-app)
- [rest api](https://docs.github.com/rest/orgs/personal-access-tokens#list-fine-grained-personal-access-tokens-with-access-to-organization-resources)

# Contributing, Support and Issues

We started Baton because we were tired of taking screenshots and manually building spreadsheets. We welcome contributions, and ideas, no matter how small -- our goal is to make identity and permissions sprawl less painful for everyone. If you have questions, problems, or ideas: Please open a GitHub Issue!
Expand All @@ -63,21 +68,27 @@ Usage:
Available Commands:
capabilities Get connector capabilities
completion Generate the autocompletion script for the specified shell
config Get the connector config schema
help Help about any command

Flags:
--client-id string The client ID used to authenticate with ConductorOne ($BATON_CLIENT_ID)
--client-secret string The client secret used to authenticate with ConductorOne ($BATON_CLIENT_SECRET)
-f, --file string The path to the c1z file to sync with ($BATON_FILE) (default "sync.c1z")
-h, --help help for baton-github
--instance-url string The GitHub instance URL to connect to. (default "https://github.com") ($BATON_INSTANCE_URL)
--log-format string The output format for logs: json, console ($BATON_LOG_FORMAT) (default "json")
--log-level string The log level: debug, info, warn, error ($BATON_LOG_LEVEL) (default "info")
--orgs strings Limit syncing to specific organizations. ($BATON_ORGS)
-p, --provisioning This must be set in order for provisioning actions to be enabled ($BATON_PROVISIONING)
--ticketing This must be set to enable ticketing support ($BATON_TICKETING)
--token string required: The GitHub access token used to connect to the GitHub API. ($BATON_TOKEN)
-v, --version version for baton-github
--client-id string The client ID used to authenticate with ConductorOne ($BATON_CLIENT_ID)
--client-secret string The client secret used to authenticate with ConductorOne ($BATON_CLIENT_SECRET)
--external-resource-c1z string The path to the c1z file to sync external baton resources with ($BATON_EXTERNAL_RESOURCE_C1Z)
--external-resource-entitlement-id-filter string The entitlement that external users, groups must have access to sync external baton resources ($BATON_EXTERNAL_RESOURCE_ENTITLEMENT_ID_FILTER)
-f, --file string The path to the c1z file to sync with ($BATON_FILE) (default "sync.c1z")
-h, --help help for baton-github
--instance-url string The GitHub instance URL to connect to. (default "https://github.com") ($BATON_INSTANCE_URL)
--log-format string The output format for logs: json, console ($BATON_LOG_FORMAT) (default "json")
--log-level string The log level: debug, info, warn, error ($BATON_LOG_LEVEL) (default "info")
--orgs strings Limit syncing to specific organizations. ($BATON_ORGS)
--otel-collector-endpoint string The endpoint of the OpenTelemetry collector to send observability data to (used for both tracing and logging if specific endpoints are not provided) ($BATON_OTEL_COLLECTOR_ENDPOINT)
-p, --provisioning This must be set in order for provisioning actions to be enabled ($BATON_PROVISIONING)
--skip-full-sync This must be set to skip a full sync ($BATON_SKIP_FULL_SYNC)
--ticketing This must be set to enable ticketing support ($BATON_TICKETING)
--token string required: The GitHub access token used to connect to the GitHub API. ($BATON_TOKEN)
--sync-secrets Whether to sync secrets or not ($BATON_SYNC_SECRETS)
-v, --version version for baton-github

Use "baton-github [command] --help" for more information about a command.
```
Expand Down
22 changes: 10 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@ module github.com/conductorone/baton-github

go 1.23.4

toolchain go1.23.6

require (
github.com/conductorone/baton-sdk v0.3.8
github.com/deckarep/golang-set/v2 v2.7.0
github.com/deckarep/golang-set/v2 v2.8.0
github.com/ennyjfrick/ruleguard-logfatal v0.0.2
github.com/google/go-github/v63 v63.0.0
github.com/google/go-github/v69 v69.2.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/migueleliasweb/go-github-mock v0.0.23
github.com/migueleliasweb/go-github-mock v1.1.0
github.com/quasilyte/go-ruleguard/dsl v0.3.22
github.com/shurcooL/githubv4 v0.0.0-20240120211514-18a1ae0e79dc
github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7
github.com/stretchr/testify v1.10.0
go.uber.org/zap v1.27.0
golang.org/x/oauth2 v0.26.0
golang.org/x/text v0.22.0
google.golang.org/grpc v1.71.0
google.golang.org/protobuf v1.36.5
golang.org/x/oauth2 v0.29.0
golang.org/x/text v0.24.0
google.golang.org/grpc v1.71.1
google.golang.org/protobuf v1.36.6
)

require (
Expand Down Expand Up @@ -63,7 +61,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-github/v59 v59.0.0 // indirect
github.com/google/go-github/v64 v64.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
Expand Down Expand Up @@ -119,7 +117,7 @@ require (
golang.org/x/crypto v0.34.0 // indirect
golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c // indirect
golang.org/x/net v0.35.0 // indirect
golang.org/x/sync v0.11.0 // indirect
golang.org/x/sync v0.13.0 // indirect
golang.org/x/sys v0.30.0 // indirect
golang.org/x/time v0.8.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect
Expand Down
Loading
Loading