SkuldNorniern / fluere

Fluere is a powerful and versatile tool designed for network monitoring and analysis. It is capable of capturing network packets in pcap format and converting them into NetFlow data, providing a comprehensive view of network traffic. It also Provides Terminal User Interface.
Apache License 2.0
29 stars 3 forks source link

Fix directory creation failure on macOS #75

Closed sweep-ai[bot] closed 8 months ago

sweep-ai[bot] commented 8 months ago

PR Feedback: 👎

Description

This PR fixes the issue where directory creation fails on macOS due to an incorrect assumption about the home directory path. The problem occurs when the application tries to create a directory at "/home//.config/fluere", which is not valid on macOS. The fix involves modifying the home_config_path function in the init.rs file to correctly construct the home directory path using the dirs::home_dir function from the dirs crate.

Summary of Changes

Please review and merge this PR to resolve the directory creation failure on macOS.

Fixes #74.


🎉 Latest improvements to Sweep:


💡 To get Sweep to edit this pull request, you can:

sweep-ai[bot] commented 8 months ago

Sandbox Executions

trunk fmt fluere-config/src/init.rs || exit 0 1/2 ✓
Checked 1 file
✔ No issues
trunk check --fix --print-failures fluere-config/src/init.rs 2/2 ❌ (`1`)
  FAILURES  
 clippy  fluere-config  .trunk/out/La6ok.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 1 file
✖ No issues, 1 failure
# .trunk/out/La6ok.yaml
trunk_cli_version: 1.17.1
title: "Error while executing: fluere-config"
report:
  - Unable to find fluere-config for Cargo.lock in any parent directory of /repo/fluere-config
  - linter:
      command: |
        /root/.cache/trunk/tools/rust/1.65.0-f09848e9e4f55504aac7f8b8e2f48445/bin/cargo clippy --message-format json --locked -- --cap-lints=warn --no-deps
      stdin_path: (none)
      run_from: /repo/fluere-config
      timeout: 10m
      rerun: (cd /repo/fluere-config; env -i PATH=/root/.cache/trunk/tools/rust/1.65.0-f09848e9e4f55504aac7f8b8e2f48445/bin:/root/.nvm/versions/node/v18.17.0/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin CARGO_HOME=/root/.cache/trunk/repos/f97b771eaa16b34ad180abf83b26f9a7/results/clippy-current/cargo_home CARGO_TARGET_DIR=/root/.cache/trunk/repos/f97b771eaa16b34ad180abf83b26f9a7/results/clippy-current/cargo_target_dir HOME=/root /root/.cache/trunk/tools/rust/1.65.0-f09848e9e4f55504aac7f8b8e2f48445/bin/cargo clippy --message-format json --locked -- --cap-lints=warn --no-deps)
      affects_cache:
        - Cargo.toml
      direct_configs:
        []
      exit_status: exited
      exit_code: 101
      stdout: (none)
      stderr: |
            Updating crates.io index
            Updating git repository `https://github.com/SkuldNorniern/pcap`
        error: the lock file /repo/Cargo.lock needs to be updated but --locked was passed to prevent this
        If you want to try to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.
    parser: |
      (none)

trunk fmt repo/Cargo.lock || exit 0 1/2 ✓
Found no applicable linters for the requested path
trunk check --fix --print-failures repo/Cargo.lock 2/2 ✓
  NOTICES  
 repo/Cargo.lock  ignored by .gitignore and trunk.yaml [git-diff-check]
 Hint: use --force to check ignored files
Found no applicable linters for the requested path

trunk fmt CI/CD configuration file || exit 0 1/2 ✓
✖ 'CI/CD' does not exist
trunk check --fix --print-failures CI/CD configuration file 2/2 ❌ (`1`)
✖ 'CI/CD' does not exist

trunk fmt CI/CD configuration file || exit 0 1/2 ✓
✖ 'CI/CD' does not exist
trunk check --fix --print-failures CI/CD configuration file 2/2 ❌ (`1`)
✖ 'CI/CD' does not exist

trunk fmt .github/workflows/ci.yml || exit 0 1/2 ✓
 ✔ Formatted .github/workflows/ci.yml
Re-checking autofixed files...

Checked 1 file
✔ No issues
trunk check --fix --print-failures .github/workflows/ci.yml 2/2 ❌ (`1`)
  ISSUES  
.github/workflows/ci.yml:1:1
 1:1  high  Ensure top-level permissions are not set to write-all  checkov/CKV2_GHA_1
Checked 1 file
✖ 1 new issue

trunk fmt .github/workflows/ci.yml || exit 0 1/2 ✓
 ✔ Formatted .github/workflows/ci.yml
Re-checking autofixed files...

Checked 1 file
✔ No issues
trunk check --fix --print-failures .github/workflows/ci.yml 2/2 ✓
Checked 1 file
✔ No issues

trunk fmt .github/workflows/ci.yml || exit 0 1/2 ✓
Checked 1 file
✔ No issues
trunk check --fix --print-failures .github/workflows/ci.yml 2/2 ✓
Checked 1 file
✔ No issues

trunk fmt CI/CD configuration file || exit 0 1/2 ✓
✖ 'CI/CD' does not exist
trunk check --fix --print-failures CI/CD configuration file 2/2 ❌ (`1`)
✖ 'CI/CD' does not exist

trunk fmt .github/workflows/ci.yml || exit 0 1/2 ✓
Checked 1 file
✔ No issues
trunk check --fix --print-failures .github/workflows/ci.yml 2/2 ✓
Checked 1 file
✔ No issues

trunk fmt CI/CD configuration file || exit 0 1/2 ✓
✖ 'CI/CD' does not exist
trunk check --fix --print-failures CI/CD configuration file 2/2 ❌ (`1`)
✖ 'CI/CD' does not exist

trunk fmt CI/CD configuration file || exit 0 1/2 ✓
✖ 'CI/CD' does not exist
trunk check --fix --print-failures CI/CD configuration file 2/2 ❌ (`1`)
✖ 'CI/CD' does not exist

trunk fmt CI/CD configuration file || exit 0 1/2 ✓
✖ 'CI/CD' does not exist
trunk check --fix --print-failures CI/CD configuration file 2/2 ❌ (`1`)
✖ 'CI/CD' does not exist

trunk fmt fluere-config/src/init.rs || exit 0 1/2 ✓
Checked 1 file
✔ No issues
trunk check --fix --print-failures fluere-config/src/init.rs 2/2 ❌ (`1`)
  FAILURES  
 clippy  fluere-config  .trunk/out/La6ok.yaml
  NOTICES  
 A tool failed to run. You can open the details yaml file for more information.
Checked 1 file
✖ No issues, 1 failure
# .trunk/out/La6ok.yaml
trunk_cli_version: 1.17.1
title: "Error while executing: fluere-config"
report:
  - Unable to find fluere-config for Cargo.lock in any parent directory of /repo/fluere-config
  - linter:
      command: |
        /root/.cache/trunk/tools/rust/1.65.0-f09848e9e4f55504aac7f8b8e2f48445/bin/cargo clippy --message-format json --locked -- --cap-lints=warn --no-deps
      stdin_path: (none)
      run_from: /repo/fluere-config
      timeout: 10m
      rerun: (cd /repo/fluere-config; env -i PATH=/root/.cache/trunk/tools/rust/1.65.0-f09848e9e4f55504aac7f8b8e2f48445/bin:/root/.nvm/versions/node/v18.17.0/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin CARGO_HOME=/root/.cache/trunk/repos/f97b771eaa16b34ad180abf83b26f9a7/results/clippy-current/cargo_home CARGO_TARGET_DIR=/root/.cache/trunk/repos/f97b771eaa16b34ad180abf83b26f9a7/results/clippy-current/cargo_target_dir HOME=/root /root/.cache/trunk/tools/rust/1.65.0-f09848e9e4f55504aac7f8b8e2f48445/bin/cargo clippy --message-format json --locked -- --cap-lints=warn --no-deps)
      affects_cache:
        - Cargo.toml
      direct_configs:
        []
      exit_status: exited
      exit_code: 101
      stdout: (none)
      stderr: |
            Updating crates.io index
            Updating git repository `https://github.com/SkuldNorniern/pcap`
        error: the lock file /repo/Cargo.lock needs to be updated but --locked was passed to prevent this
        If you want to try to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.
    parser: |
      (none)

sweep-ai[bot] commented 8 months ago

Apply Sweep Rules to your PR?

coderabbitai[bot] commented 8 months ago

[!IMPORTANT]

Auto Review Skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.


Tips ### Chat with CodeRabbit Bot (`@coderabbitai`) - If you reply to a *review comment* from CodeRabbit, the bot will automatically respond. - To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment - Note: Review comments are made on code diffs or files, not on the PR overview. - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai help` to get help. - `@coderabbitai resolve` to resolve all the CodeRabbit review comments. Note: For conversation with the bot, please use the review comments on code diffs or files. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - The JSON schema for the configuration file is available [here](https://coderabbit.ai/integrations/coderabbit-overrides.json). - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.json`
SkuldNorniern commented 8 months ago

when the config file is not found, automatically create the config file

sweep-ai[bot] commented 8 months ago

🚀 Wrote Changes

Done.

SkuldNorniern commented 8 months ago

on the path, the user name appears twice, fix the issue

path_file: "/Users/<user>/<user>/.config/fluere/fluere.toml"
sweep-ai[bot] commented 8 months ago

🚀 Wrote Changes

Done.

SkuldNorniern commented 8 months ago

on linux, there is no user name on the config, but on the macOS side, it it fixed use the derive to fix that per OS

sweep-ai[bot] commented 8 months ago

🚀 Wrote Changes

Done.