Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@
# latest / main
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Container ${{ github.repository }}
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
id: build
Expand All @@ -106,6 +113,9 @@
labels: ${{ steps.meta.outputs.labels }}
# SBOM Settings
sbom: true
# Pass GitHub token as a build secret
secrets: |
"github_token=${{ secrets.GITHUB_TOKEN }}"
# Upload Software Bill of Materials (SBOM) to GitHub
- name: Upload SBOM
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,20 @@
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Define GitHub token as a build ARG
ARG github_token

Check warning on line 35 in Dockerfile

View workflow job for this annotation

GitHub Actions / container

Sensitive data should not be used in the ARG or ENV commands

SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "github_token") More info: https://docs.docker.com/go/dockerfile/rule/secrets-used-in-arg-or-env/

# Install the CodeQL extension for GitHub CLI
RUN --mount=type=secret,id=github_token \
if [ -f "/run/secrets/github_token" ]; then \
export GITHUB_TOKEN=$(cat /run/secrets/github_token); \
gh auth setup-git; \
gh extensions install github/gh-codeql && \
gh codeql install-stub; \
else \
echo "No GitHub token provided, using public access"; \
gh extensions install github/gh-codeql && \
gh codeql install-stub; \
fi

ENTRYPOINT [ "codeql-extractor-action" ]
13 changes: 13 additions & 0 deletions src/extractors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ pub async fn fetch_extractor(
}
};

// Get and log the size of the extractor archive
if let Ok(metadata) = std::fs::metadata(&extractor_archive) {
let size_bytes = metadata.len();
let size_mb = size_bytes as f64 / 1_048_576.0; // Convert to MB (1 MB = 1,048,576 bytes)
log::info!(
"Extractor archive size: {:.2} MB ({} bytes)",
size_mb,
size_bytes
);
} else {
log::warn!("Unable to get size information for the extractor archive");
}

if attest {
log::info!("Attesting asset {extractor_tarball:?}");

Expand Down
16 changes: 12 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ async fn main() -> Result<()> {
if !codeql.is_installed().await {
let codeql_version = action.codeql_version();
log::info!("CodeQL not installed, installing `{codeql_version}`...");
codeql
.install(&octocrab, codeql_version)
.await
.context("Failed to install CodeQL")?;

if let Err(error) = codeql.install(&octocrab, codeql_version).await {
log::warn!("Failed to install CodeQL: {error:?}");
log::info!("Attempting to install CodeQL using GitHub CLI...");

tokio::process::Command::new("gh")
.args(&["codeql", "set-version", codeql_version.into()])
.status()
.await
.context("Failed to execute `gh codeql set-version` command")?;
}

log::info!("CodeQL installed");
} else {
log::info!("CodeQL already installed");
Expand Down
Loading