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

✨ Added warning when pushing sensitive files #73

Merged
merged 9 commits into from
Jun 30, 2024

Conversation

Mario-SO
Copy link
Contributor

@Mario-SO Mario-SO commented Jun 27, 2024

As discussed in here for issue #67, added a user warning when pushing .env or .git/

PS: Missing tests, looking forward to feedback.

@Mario-SO Mario-SO changed the title ✨ Added warning when pushing sensitive files #67 ✨ Added warning when pushing sensitive files Jun 27, 2024
@mario-eth
Copy link
Owner

It seems that we differ in fmt settings? cause i see there are many changes on how the imports are done?
i use the foundry ones:
https://github.com/foundry-rs/foundry/blob/master/CONTRIBUTING.md

src/lib.rs Outdated
let path_buf = PathBuf::from(&path);

// Check for sensitive files or directories
if utils::check_for_sensitive_files_or_directories_recursive(&path_buf) {
Copy link
Owner

Choose a reason for hiding this comment

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

just import this so you can use it check_for_sensitive_files_or_directories_recursive

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't get what you mean here

src/lib.rs Outdated
let _ = remove_dir_all(&test_dir);

// Restore the original prompt function
// utils::prompt_user_for_confirmation = original_prompt;
Copy link
Owner

Choose a reason for hiding this comment

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

is this needed?

src/utils.rs Outdated
// Function to check for the presence of sensitive files or directories
pub fn check_for_sensitive_files_or_directories(path: &Path) -> bool {
let env_file_exists = path.join(".env").exists();
let git_dir_exists = path.join(".git").exists();
Copy link
Owner

Choose a reason for hiding this comment

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

maybe we can just look for any .file we have? and just display them all?
And let the user decide if it's safe?

Copy link
Owner

Choose a reason for hiding this comment

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

cause it may be more . files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense yeah.

@Mario-SO
Copy link
Contributor Author

It seems that we differ in fmt settings? cause i see there are many changes on how the imports are done?

i use the foundry ones:

https://github.com/foundry-rs/foundry/blob/master/CONTRIBUTING.md

Crap, you are totally right, my bad. Will fix and PR again.

PS: Also saw the rest of the comments you made.

src/lib.rs Outdated
let path_buf = PathBuf::from(&path);

// Check for sensitive files or directories
if utils::check_for_sensitive_files_or_directories_recursive(&path_buf) {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if utils::check_for_sensitive_files_or_directories_recursive(&path_buf) {
if check_for_sensitive_files_or_directories_recursive(&path_buf) {

Sorry i just meant like this.

Copy link
Owner

Choose a reason for hiding this comment

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

also the name is a bit tbh, can we work on something smaller?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh ok I get you now, also, yeah the name is way too descriptive XD

@mario-eth
Copy link
Owner

you have to run
cargo +nightly clippy --workspace --all-targets --all-features
And resolve them

and
cargo +nightly fmt --all --check

Cause the CI fails

@Mario-SO
Copy link
Contributor Author

Ok I see, sorry for all the inconveniences this PR is causing first of all.

Also wanted to ask, when running cargo +nightly clippy --workspace --all-targets --all-features, there is a warning in file dependency_downloader.rs which is a file I didn't touch at all. The warning is this one

warning: this function depends on never type fallback being `()`
  --> src/dependency_downloader.rs:18:1
   |
18 | / pub async fn download_dependencies(
19 | |     dependencies: &[Dependency],
20 | |     clean: bool,
21 | | ) -> Result<(), DownloadError> {
   | |______________________________^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
   = help: specify the types explicitly
note: in edition 2024, the requirement `!: std::iter::FromIterator<()>` will fail
  --> src/dependency_downloader.rs:35:16
   |
35 |     .collect::<Result<_, _>>()?;
   |                ^^^^^^^^^^^^
   = note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default

The rest of the warnings are resolved and also ran the cargo +nightly fmt --all --check.

I will push again and await your feedback once more.

Again sorry to bother this much with such a minor PR.

@mario-eth
Copy link
Owner

Ok I see, sorry for all the inconveniences this PR is causing first of all.

Also wanted to ask, when running cargo +nightly clippy --workspace --all-targets --all-features, there is a warning in file dependency_downloader.rs which is a file I didn't touch at all. The warning is this one

warning: this function depends on never type fallback being `()`
  --> src/dependency_downloader.rs:18:1
   |
18 | / pub async fn download_dependencies(
19 | |     dependencies: &[Dependency],
20 | |     clean: bool,
21 | | ) -> Result<(), DownloadError> {
   | |______________________________^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
   = help: specify the types explicitly
note: in edition 2024, the requirement `!: std::iter::FromIterator<()>` will fail
  --> src/dependency_downloader.rs:35:16
   |
35 |     .collect::<Result<_, _>>()?;
   |                ^^^^^^^^^^^^
   = note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default

The rest of the warnings are resolved and also ran the cargo +nightly fmt --all --check.

I will push again and await your feedback once more.

Again sorry to bother this much with such a minor PR.

ah no worries at all, thank you for taking the time to get this done.
That is weird, it seems it's like a new compiler warning, can you solve it?

@Mario-SO
Copy link
Contributor Author

Sure, will solve it asap

@mario-eth
Copy link
Owner

actually i m gonna solve them cause it seems there are more now after I did an update. will solve then if everything is ok I m gonna merge this one

@Mario-SO
Copy link
Contributor Author

It no longer pops any warnings.

@mario-eth mario-eth merged commit 53996ea into mario-eth:main Jun 30, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants