Skip to content

Commit

Permalink
Improve README wording and output
Browse files Browse the repository at this point in the history
  • Loading branch information
tstromberg committed Jan 12, 2023
1 parent 8d183ea commit 47ebb91
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ Sync Secureframe tests to GitHub issues:
* Updates Github issues when test details change
* Closes Github issues when a test passes or is disabled

secureframe-issue-sync is designed to be used as a scheduled task, and perfect for deploying via Github Actions.
secureframe-issue-sync is designed to be used as a scheduled task, and is perfect for deploying via Github Actions.

NOTE: This is using an undocumented Secureframe GraphQL API, so it may suddenly break. PR's welcome.

## Requirements

* A GitHub API token
* A Secureframe API token
* A Secureframe Company ID
* A GitHub API token (preferably fine-grained for just issue management)
* A Secureframe API token (findable via browser headers)
* A Secureframe Company ID (findable via browser headers)

As Secureframe does not yet have a public API, you'll need to grab the latter two bits of information using your browser's Developer Tools functionality.
As Secureframe does not yet have a public API, you'll need to grab the latter two bits of information using your browser's Developer Tools functionality.

1. Visit <https://app.secureframe.com/dashboard/incomplete-tests/soc2-beta> or other dashboard page
2. Enter your browsers "Developer Tools"
3. Reload the page
4. Look for the `graphql` request that calls the `getDashboardTests` operation
5. Click the `Headers` tab
6. Look for the `authorization` header, it will have a value in the form of `Bearer lr45laoeu21z4`: That is your Secureframe API token.
4. Look for a `graphql` request
5. Click the `Headers` tab
6. Look for the `authorization` request header, it will have a value in the form of `Bearer lr45laoeu21z4`: This is your Secureframe API token.
9. Click the `Payload` tab to capture the company ID and report keys to use.

## Usage: Github Actions
## Usage: GitHub Actions

In production, your going to want to schedule the sync job to run every hour or so. Since you are already on Github, why not use Github Actions to do it?
In production, you're going to want to schedule the sync job to run every hour or so. Since you are already on Github, why not use Github Actions to do it?

See https://github.com/chainguard-dev/secureframe-issue-sync/blob/main/github-action.yaml for an example.
See <https://github.com/chainguard-dev/secureframe-issue-sync/blob/main/github-action.yaml> for an example.

## Usage: Command-line

`go run . --secureframe-token=<token> --reports=soc2_alpha --github-token=<token> --github-repo=chainguard-dev/xyz --github-label=soc2`
`go run . --secureframe-token=<token> --reports=soc2_alpha --github-token=<token> --github-repo=chainguard-dev/xyz`

There is a `--dry-run` flag available.

Expand Down
7 changes: 7 additions & 0 deletions pkg/issue/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ func Synced(ctx context.Context, gc *github.Client, org string, project string)
}

func SyncLabels(ctx context.Context, gc *github.Client, org string, project string, labels []string) error {
log.Printf("syncing Github labels: %s", labels)
desc := "Added by secureframe-issue-sync"

for _, l := range labels {
if l == "" {
continue
}
_, _, err := gc.Issues.GetLabel(ctx, org, project, l)
// not there?
if err != nil {
Expand All @@ -83,6 +87,7 @@ func SyncLabels(ctx context.Context, gc *github.Client, org string, project stri

// Create creates an issue
func Create(ctx context.Context, gc *github.Client, org string, project string, ft IssueForm) error {
log.Printf("creating github issue: %s", ft.Title)
i := &github.IssueRequest{
Title: &ft.Title,
Body: &ft.Body,
Expand All @@ -95,6 +100,7 @@ func Create(ctx context.Context, gc *github.Client, org string, project string,

// Update creates an issue
func Update(ctx context.Context, gc *github.Client, org string, project string, id int, ft IssueForm) error {
log.Printf("updating github issue: %s", ft.Title)
i := &github.IssueRequest{
Title: &ft.Title,
Body: &ft.Body,
Expand All @@ -108,6 +114,7 @@ func Update(ctx context.Context, gc *github.Client, org string, project string,
// Close closes an issue
func Close(ctx context.Context, gc *github.Client, org string, project string, i *github.Issue, label string) error {
title := i.GetTitle()
log.Printf("closing github issue: %s", title)
body := i.GetBody()
labels := []string{}
for _, l := range i.Labels {
Expand Down

0 comments on commit 47ebb91

Please sign in to comment.