Skip to content

Commit 32500bb

Browse files
aldevvbtipling
authored andcommitted
add secrets resource
update readme fix config file fix github deprecated calls fix github deprecated calls 2 fix lint warnings refactor resource type add secrets resource fix github deprecated calls fix getUserBySlug using id instead of name, remove dead code fix lint fix readme update golangci-lint use v8
1 parent 453a4da commit 32500bb

File tree

404 files changed

+18516
-10212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

404 files changed

+18516
-10212
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
- name: Checkout code
1212
uses: actions/checkout@v3
1313
- name: Run linters
14-
uses: golangci/golangci-lint-action@v3
14+
uses: golangci/golangci-lint-action@v8
1515
with:
16-
version: latest
16+
version: v2.1.6
1717
args: --timeout=3m
1818
go-test:
1919
strategy:

.golangci.yml

Lines changed: 112 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,116 @@
1-
#AUTO GENERATED CODE. UPDATE THE CONFIG IN BATON-TEMPLATE FIRST
2-
linters-settings:
3-
exhaustive:
4-
default-signifies-exhaustive: true
5-
gocritic:
6-
enabled-checks:
7-
- ruleguard
8-
# The list of supported checkers can be find in https://go-critic.github.io/overview.
9-
settings:
10-
underef:
11-
# Whether to skip (*x).method() calls where x is a pointer receiver.
12-
skipRecvDeref: false
13-
ruleguard:
14-
rules: "${configDir}/tools/rules.go"
15-
govet:
16-
enable-all: true
17-
disable:
18-
- fieldalignment # too strict
19-
- shadow # complains too much about shadowing errors. All research points to this being fine.
20-
nakedret:
21-
max-func-lines: 0
22-
nolintlint:
23-
allow-no-explanation: [forbidigo, tracecheck, gomnd, gochecknoinits, makezero]
24-
require-explanation: true
25-
require-specific: true
26-
revive:
27-
ignore-generated-header: true
28-
severity: error
29-
rules:
30-
- name: atomic
31-
- name: line-length-limit
32-
arguments: [200]
33-
# These are functions that we use without checking the errors often. Most of these can't return an error even
34-
# though they implement an interface that can.
35-
- name: unhandled-error
36-
arguments:
37-
- fmt.Printf
38-
- fmt.Println
39-
- fmt.Fprint
40-
- fmt.Fprintf
41-
- fmt.Fprintln
42-
- os.Stderr.Sync
43-
- sb.WriteString
44-
- buf.WriteString
45-
- hasher.Write
46-
- os.Setenv
47-
- os.RemoveAll
48-
- name: var-naming
49-
arguments: [["ID", "URL", "HTTP", "API"], []]
50-
tenv:
51-
all: true
1+
version: "2"
522
linters:
53-
disable-all: true
3+
default: none
544
enable:
55-
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
56-
- gosimple # Linter for Go source code that specializes in simplifying a code
57-
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
58-
- ineffassign # Detects when assignments to existing variables are not used
59-
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
60-
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
61-
- unused # Checks Go code for unused constants, variables, functions and types
62-
- asasalint # Check for pass []any as any in variadic func(...any)
63-
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
64-
- bidichk # Checks for dangerous unicode character sequences
65-
- bodyclose # checks whether HTTP response body is closed successfully
66-
- durationcheck # check for two durations multiplied together
67-
- 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.
68-
- exhaustive # check exhaustiveness of enum switch statements
69-
- forbidigo # Forbids identifiers
70-
- gochecknoinits # Checks that no init functions are present in Go code
71-
- goconst # Finds repeated strings that could be replaced by a constant
72-
- gocritic # Provides diagnostics that check for bugs, performance and style issues.
73-
- godot # Check if comments end in a period
74-
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt.
75-
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
76-
- goprintffuncname # Checks that printf-like functions are named with f at the end
77-
- gosec # Inspects source code for security problems
78-
- nakedret # Finds naked returns in functions greater than a specified function length
79-
- nilerr # Finds the code that returns nil even if it checks that the error is not nil.
80-
- noctx # noctx finds sending http request without context.Context
81-
- nolintlint # Reports ill-formed or insufficient nolint directives
82-
- nonamedreturns # Reports all named returns
83-
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.
84-
- predeclared # find code that shadows one of Go's predeclared identifiers
85-
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
86-
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
87-
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
88-
- unconvert # Remove unnecessary type conversions
89-
- usestdlibvars # detect the possibility to use variables/constants from the Go standard library
90-
- whitespace # Tool for detection of leading and trailing whitespace
5+
- asasalint
6+
- asciicheck
7+
- bidichk
8+
- bodyclose
9+
- durationcheck
10+
- errcheck
11+
- errorlint
12+
- exhaustive
13+
- forbidigo
14+
- gochecknoinits
15+
- goconst
16+
- gocritic
17+
- godot
18+
- gomoddirectives
19+
- goprintffuncname
20+
- gosec
21+
- govet
22+
- ineffassign
23+
- nakedret
24+
- nilerr
25+
- noctx
26+
- nolintlint
27+
- nonamedreturns
28+
- nosprintfhostport
29+
- predeclared
30+
- revive
31+
- staticcheck
32+
- tparallel
33+
- unconvert
34+
- unused
35+
- usestdlibvars
36+
- whitespace
37+
settings:
38+
exhaustive:
39+
default-signifies-exhaustive: true
40+
gocritic:
41+
enabled-checks:
42+
- ruleguard
43+
settings:
44+
ruleguard:
45+
rules: ${base-path}/tools/rules.go
46+
underef:
47+
skipRecvDeref: false
48+
govet:
49+
disable:
50+
- fieldalignment
51+
- shadow
52+
enable-all: true
53+
nakedret:
54+
max-func-lines: 0
55+
nolintlint:
56+
require-explanation: true
57+
require-specific: true
58+
allow-no-explanation:
59+
- forbidigo
60+
- tracecheck
61+
- gomnd
62+
- gochecknoinits
63+
- makezero
64+
revive:
65+
severity: error
66+
rules:
67+
- name: atomic
68+
- name: line-length-limit
69+
arguments:
70+
- 200
71+
- name: unhandled-error
72+
arguments:
73+
- fmt.Printf
74+
- fmt.Println
75+
- fmt.Fprint
76+
- fmt.Fprintf
77+
- fmt.Fprintln
78+
- os.Stderr.Sync
79+
- sb.WriteString
80+
- buf.WriteString
81+
- hasher.Write
82+
- os.Setenv
83+
- os.RemoveAll
84+
- name: var-naming
85+
arguments:
86+
- - ID
87+
- URL
88+
- HTTP
89+
- API
90+
- []
91+
exclusions:
92+
generated: lax
93+
presets:
94+
- comments
95+
- common-false-positives
96+
- legacy
97+
- std-error-handling
98+
rules:
99+
- linters:
100+
- godot
101+
source: (TODO)
102+
paths:
103+
- third_party$
104+
- builtin$
105+
- examples$
91106
issues:
92107
max-same-issues: 50
93-
exclude-rules:
94-
# Don't require TODO comments to end in a period
95-
- source: "(TODO)"
96-
linters: [godot]
108+
formatters:
109+
enable:
110+
- goimports
111+
exclusions:
112+
generated: lax
113+
paths:
114+
- third_party$
115+
- builtin$
116+
- examples$

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ add-dep:
4040
.PHONY: lint
4141
lint:
4242
golangci-lint run
43-

README.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ baton resources
4545

4646
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.
4747

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

5055
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!
@@ -63,21 +68,27 @@ Usage:
6368
Available Commands:
6469
capabilities Get connector capabilities
6570
completion Generate the autocompletion script for the specified shell
71+
config Get the connector config schema
6672
help Help about any command
6773
6874
Flags:
69-
--client-id string The client ID used to authenticate with ConductorOne ($BATON_CLIENT_ID)
70-
--client-secret string The client secret used to authenticate with ConductorOne ($BATON_CLIENT_SECRET)
71-
-f, --file string The path to the c1z file to sync with ($BATON_FILE) (default "sync.c1z")
72-
-h, --help help for baton-github
73-
--instance-url string The GitHub instance URL to connect to. (default "https://github.com") ($BATON_INSTANCE_URL)
74-
--log-format string The output format for logs: json, console ($BATON_LOG_FORMAT) (default "json")
75-
--log-level string The log level: debug, info, warn, error ($BATON_LOG_LEVEL) (default "info")
76-
--orgs strings Limit syncing to specific organizations. ($BATON_ORGS)
77-
-p, --provisioning This must be set in order for provisioning actions to be enabled ($BATON_PROVISIONING)
78-
--ticketing This must be set to enable ticketing support ($BATON_TICKETING)
79-
--token string required: The GitHub access token used to connect to the GitHub API. ($BATON_TOKEN)
80-
-v, --version version for baton-github
75+
--client-id string The client ID used to authenticate with ConductorOne ($BATON_CLIENT_ID)
76+
--client-secret string The client secret used to authenticate with ConductorOne ($BATON_CLIENT_SECRET)
77+
--external-resource-c1z string The path to the c1z file to sync external baton resources with ($BATON_EXTERNAL_RESOURCE_C1Z)
78+
--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)
79+
-f, --file string The path to the c1z file to sync with ($BATON_FILE) (default "sync.c1z")
80+
-h, --help help for baton-github
81+
--instance-url string The GitHub instance URL to connect to. (default "https://github.com") ($BATON_INSTANCE_URL)
82+
--log-format string The output format for logs: json, console ($BATON_LOG_FORMAT) (default "json")
83+
--log-level string The log level: debug, info, warn, error ($BATON_LOG_LEVEL) (default "info")
84+
--orgs strings Limit syncing to specific organizations. ($BATON_ORGS)
85+
--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)
86+
-p, --provisioning This must be set in order for provisioning actions to be enabled ($BATON_PROVISIONING)
87+
--skip-full-sync This must be set to skip a full sync ($BATON_SKIP_FULL_SYNC)
88+
--ticketing This must be set to enable ticketing support ($BATON_TICKETING)
89+
--token string required: The GitHub access token used to connect to the GitHub API. ($BATON_TOKEN)
90+
--sync-secrets Whether to sync secrets or not ($BATON_SYNC_SECRETS)
91+
-v, --version version for baton-github
8192
8293
Use "baton-github [command] --help" for more information about a command.
8394
```

go.mod

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@ module github.com/conductorone/baton-github
22

33
go 1.23.4
44

5-
toolchain go1.23.6
6-
75
require (
86
github.com/conductorone/baton-sdk v0.3.8
9-
github.com/deckarep/golang-set/v2 v2.7.0
7+
github.com/deckarep/golang-set/v2 v2.8.0
108
github.com/ennyjfrick/ruleguard-logfatal v0.0.2
11-
github.com/google/go-github/v63 v63.0.0
9+
github.com/google/go-github/v69 v69.2.0
1210
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
13-
github.com/migueleliasweb/go-github-mock v0.0.23
11+
github.com/migueleliasweb/go-github-mock v1.1.0
1412
github.com/quasilyte/go-ruleguard/dsl v0.3.22
15-
github.com/shurcooL/githubv4 v0.0.0-20240120211514-18a1ae0e79dc
13+
github.com/shurcooL/githubv4 v0.0.0-20240727222349-48295856cce7
1614
github.com/stretchr/testify v1.10.0
1715
go.uber.org/zap v1.27.0
18-
golang.org/x/oauth2 v0.26.0
19-
golang.org/x/text v0.22.0
20-
google.golang.org/grpc v1.71.0
21-
google.golang.org/protobuf v1.36.5
16+
golang.org/x/oauth2 v0.29.0
17+
golang.org/x/text v0.24.0
18+
google.golang.org/grpc v1.71.1
19+
google.golang.org/protobuf v1.36.6
2220
)
2321

2422
require (
@@ -63,7 +61,7 @@ require (
6361
github.com/go-logr/stdr v1.2.2 // indirect
6462
github.com/go-ole/go-ole v1.3.0 // indirect
6563
github.com/golang/protobuf v1.5.4 // indirect
66-
github.com/google/go-github/v59 v59.0.0 // indirect
64+
github.com/google/go-github/v64 v64.0.0 // indirect
6765
github.com/google/go-querystring v1.1.0 // indirect
6866
github.com/google/uuid v1.6.0 // indirect
6967
github.com/gorilla/mux v1.8.0 // indirect
@@ -119,7 +117,7 @@ require (
119117
golang.org/x/crypto v0.34.0 // indirect
120118
golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c // indirect
121119
golang.org/x/net v0.35.0 // indirect
122-
golang.org/x/sync v0.11.0 // indirect
120+
golang.org/x/sync v0.13.0 // indirect
123121
golang.org/x/sys v0.30.0 // indirect
124122
golang.org/x/time v0.8.0 // indirect
125123
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect

0 commit comments

Comments
 (0)