Skip to content

GO Compiled lang troubleshooting #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions troubleshooting/codeql-builds/compiled-languages-go.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## GoLang Private Modules

Autobuild fails with error "Some packages could not be found"

There are two options when it comes to private repositories:

- Set-up the Go environment within the Actions workflow (not vendoring then)
- Vendor the dependencies

Setting up the Go environment can be done by adding a Actions step to update the [Go settings](https://go.dev/ref/mod#private-modules) pointing them to use a [GitHub Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) with the corresponding access to the private repository.
The example below shows how this can be done using a single step beforet the CodeQL Initize step and stores the GitHub PAT in Secrets.

**Example:**

```yml
name: CodeQL

env:
GOLANG_TOKEN: ${{ secrets.GOLANG_GITHUB_TOKEN }}
GOLANG_USER: octocat

# ...
jobs:
analyze:
name: Analyze
# ...
steps:
- name: Go Configuration
run: git config --global url."https://${GOLANG_USER}:${GOLANG_TOKEN}@github.com".insteadOf "https://github.com"

# ... Start scanning
```

Alternatively, pass the token into the CodeQL init action to allow it to be used for downstream git operations:

```yml
- uses: github/codeql-action/init@v2
with:
external-repository-token: ${{ secrets.GOLANG_GITHUB_TOKEN }}
```
1 change: 1 addition & 0 deletions troubleshooting/codeql-builds/compiled-languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [CSharp](compiled-languages-csharp.md)
* [C++](compiled-languages-cpp.md)
* [Java](compiled-languages-java.md)
* [Go](compiled-languages-go.md)

## Autobuilder
The autobuilder action (see [docs](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#about-autobuild-for-codeql) )
Expand Down