Skip to content
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

buck2/20241001-r2: cve remediation #35900

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

octo-sts[bot]
Copy link
Contributor

@octo-sts octo-sts bot commented Dec 5, 2024

@octo-sts octo-sts bot added P0 This label indicates our scanning found CRITICAL CVEs for these packages. automated pr GHSA-wwq9-3cpr-mm53 request-cve-remediation rust/cargobump buck2/20241001-r2 labels Dec 5, 2024
Copy link
Contributor Author

octo-sts bot commented Dec 5, 2024

Gen AI suggestions to solve the build error:

• Detected Error: "Error: failed reading file: open Cargo.lock: no such file or directory"

• Error Category: Build Configuration

• Failure Point: The rust/cargobump step failing due to missing Cargo.lock file

• Root Cause Analysis: The cargobump step expects to find a Cargo.lock file in the root directory, but it doesn't exist because cargo build hasn't been run yet to generate it.

• Suggested Fix:

  1. Remove the rust/cargobump step since it's not needed for this build
    OR
  2. Generate the Cargo.lock file before running cargobump by adding:
  - name: Generate Cargo.lock
    runs: |
      cd app/buck2
      cargo generate-lockfile
  
  - uses: rust/cargobump

• Explanation: The build is failing because the cargobump step is looking for a Cargo.lock file that doesn't exist yet. Since this is a direct build from a Git tag, we either need to generate the lockfile first or remove the cargobump step if dependency bumping isn't required.

• Additional Notes:

  • The cargobump step is typically used when you need to update dependencies, but may not be necessary when building from a specific tag
  • If dependency bumping is required, generating the lockfile first ensures cargobump has the file it needs to work with
  • The error occurs before the actual build starts, so the rest of the pipeline is sound

• References:

@maxgio92 maxgio92 self-assigned this Dec 6, 2024
Signed-off-by: Massimiliano Giovagnoli <[email protected]>
@@ -0,0 +1,3 @@
packages:
- name: hashbrown
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are multiple versions of hashbrown required: 0.12.3 and 0.14.5. Apparently cargo dependencies are not happy with 0.15.1 considering those requirements. To be checked.

@maxgio92 maxgio92 assigned maxgio92 and unassigned maxgio92 Dec 6, 2024
Copy link
Contributor Author

octo-sts bot commented Dec 6, 2024

Gen AI suggestions to solve the build error:

Let me analyze the build error and provide a solution.

• Detected Error:

Error: failed to parse the pom file: failed to run cargo update 'error: There are multiple `hashbrown` packages in your project, and the specification `hashbrown` is ambiguous.
Please re-run this command with one of the following specifications:
  [email protected]
  [email protected]
  [email protected]'

• Error Category: Dependency

• Failure Point: The cargobump command during the "Configure and build" step

• Root Cause Analysis: The build is failing because there are multiple versions of the hashbrown crate in the dependency tree, and cargobump cannot automatically determine which version to use.

• Suggested Fix:

  1. Create or modify the cargobump-deps.yaml file to explicitly specify the hashbrown version:
dependencies:
  hashbrown: "0.15.2"  # Use the latest version from the options

• Explanation: The cargobump tool needs explicit version information when there are multiple versions of the same package in the dependency tree. By specifying the version in cargobump-deps.yaml, we remove the ambiguity and allow the build to proceed.

• Additional Notes:

  • Version 0.15.2 is suggested as it's the newest version from the available options
  • This is a common issue in Rust projects with complex dependency trees
  • The fix aligns with Wolfi's principle of using latest versions where possible

• References:

Copy link
Contributor Author

octo-sts bot commented Dec 6, 2024

Gen AI suggestions to solve the build error:

Based on the error output, I'll analyze and provide a solution:

• Detected Error: The build appears to stop after rustup installation with no explicit error message, which typically indicates a silent failure in the cargo commands that follow.

• Error Category: Build/Configuration

• Failure Point: After rustup install, likely during the cargo generate-lockfile step

• Root Cause Analysis:
The issue appears to be related to the rust toolchain version specified (nightly-2024-06-08) which is trying to be used for a package version from 2024-10-01. There's likely a version mismatch between the specified rust nightly version and what Buck2 requires for that commit.

• Suggested Fix:

  1. Update the rust-version in vars to match the required version for the October 2024 commit
  2. Check HACKING.md in the Buck2 repository at the specified commit (66770ab8) for the correct rust version
  3. Modify the yaml to use the correct rust nightly version:
vars:
  rust-version: nightly-2024-09-26  # Update to the version specified in HACKING.md for the October commit

• Explanation:
Buck2's build system is sensitive to rust toolchain versions and requires specific nightly versions as noted in their HACKING.md file. The current mismatch between the June nightly and October codebase is likely causing silent cargo failures.

• Additional Notes:

  • The build system appears to be working correctly up through the rustup installation
  • No explicit error message suggests a compatibility issue rather than a system error
  • The package version (20241001) indicates this is a recent commit that likely requires a more recent nightly version

• References:

To implement this fix:

  1. Check the HACKING.md file at commit 66770ab8
  2. Update the rust-version variable to match the required version
  3. Rebuild the package

The silent failure pattern is common in Rust builds when toolchain versions don't match requirements, and updating to the correct nightly version should resolve the issue.

@maxgio92 maxgio92 force-pushed the cve-buck2-968209209c9d422f6606fb29c9dfcfb7 branch from c912cdc to 1e7aa48 Compare December 6, 2024 22:23
Copy link
Contributor Author

octo-sts bot commented Dec 6, 2024

Gen AI suggestions to solve the build error:

Based on the error log provided, I'll analyze and provide a solution:

• Detected Error: No explicit error message is shown, but the build appears to halt after updating git repositories, specifically after "Updating git repository https://github.com/get9/hyper-proxy"

• Error Category: Dependency/Build

• Failure Point: During cargo generate-lockfile step

• Root Cause Analysis: The build appears to be timing out or hanging during dependency resolution, likely due to network issues or git dependencies that are not properly resolving.

• Suggested Fix:

  1. Add git to the environment packages list
  2. Add specific git dependency versions in cargobump-deps.yaml
  3. Add a timeout to the cargo commands
environment:
  contents:
    packages:
      - build-base
      - busybox
      - ca-certificates-bundle
      - cargo-auditable
      - cargobump
      - openssf-compiler-options
      - rustup
      - wolfi-base
      - git  # Add this line

pipeline:
  # ... previous steps ...
  - name: Configure and build
    runs: |
      rustup install ${{vars.rust-version}}
      export PATH="$HOME/.rustup/toolchains/${{vars.rust-version}}-${{host.triplet.rust}}/bin:$PATH"
      
      # Add timeout to cargo commands
      timeout 1800 cargo generate-lockfile
      timeout 1800 cargobump --bump-file cargobump-deps.yaml
      
      mkdir -p ${{targets.destdir}}/usr/bin/
      cd app/buck2
      
      timeout 1800 cargo auditable build --release
      mv ../../target/release/buck2 ${{targets.destdir}}/usr/bin/

• Explanation: The build appears to be hanging during dependency resolution. Adding timeouts and ensuring git is available will help prevent infinite waits and ensure proper dependency fetching.

• Additional Notes:

  • Consider vendoring dependencies to avoid network-related issues
  • The specific nightly rust version might have compatibility issues with some dependencies
  • Consider adding --verbose flag to cargo commands for better debugging

• References:

@maxgio92 maxgio92 removed their assignment Dec 17, 2024
Copy link
Contributor Author

octo-sts bot commented Dec 30, 2024

Gen AI suggestions to solve the build error:

Based on the build log, I'll analyze the error and provide a solution:

• Detected Error: The build appears to have stopped after updating git repositories without completing the build process, suggesting a dependency resolution or fetch issue.

• Error Category: Dependency

• Failure Point: During cargo dependency resolution after rustup installation

• Root Cause Analysis: The build is failing during the cargo dependency resolution phase, likely due to git dependencies that are either:

  1. Not properly versioned
  2. Unable to be fetched
  3. Have compatibility issues with the specified nightly rust version

• Suggested Fix:

  1. Add git to the environment.contents.packages list
  2. Pin the git dependencies in Cargo.toml to specific commits
  3. Update the cargobump-deps.yaml to include:
dependencies:
  perf-event:
    git: https://github.com/krallin/perf-event.git
    rev: <specific-commit-hash>
  hyper-proxy:
    git: https://github.com/get9/hyper-proxy
    rev: <specific-commit-hash>

• Explanation:

  • Git dependencies in Rust builds can be unstable if not pinned to specific commits
  • The build system needs explicit git package for fetching dependencies
  • Pinning dependencies ensures reproducible builds and prevents fetch failures

• Additional Notes:

  • Consider using crates.io versions instead of git dependencies where possible
  • The nightly rust version (2024-06-08) might need to be verified against these dependencies
  • Adding --verbose to cargo commands can provide more detailed error information

• References:

Would you like me to provide specific commit hashes for the git dependencies or additional debugging steps?

@kbsteere
Copy link
Contributor

kbsteere commented Jan 3, 2025

no customers are using this package, @imjasonh is looking into how we mitigate these from appearing in the queues.

@kbsteere kbsteere added P2 This issue we intend to address but we have can live without it (fixed in months/quarters) and removed P0 This label indicates our scanning found CRITICAL CVEs for these packages. labels Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automated pr buck2/20241001-r2 GHSA-wwq9-3cpr-mm53 P2 This issue we intend to address but we have can live without it (fixed in months/quarters) request-cve-remediation rust/cargobump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants