Skip to content

Commit 8339b66

Browse files
author
Gal Ben David
committed
fix scan_from_url to clone to a dir name consists of the full url
1 parent d1c5e7b commit 8339b66

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyrepscan"
3-
version = "0.9.0"
3+
version = "0.9.1"
44
authors = ["Gal Ben David <gal@intsights.com>"]
55
edition = "2018"
66
description = "A Git Repository Secrets Scanner written in Rust"
@@ -41,6 +41,7 @@ num_cpus = "1"
4141
parking_lot = "0.11"
4242
crossbeam = "0.8"
4343
crossbeam-utils = "0.8"
44+
percent-encoding = "2"
4445

4546
[dependencies.git2]
4647
version = "0.13"

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ strip = true
1414

1515
[tool.poetry]
1616
name = "pyrepscan"
17-
version = "0.9.0"
17+
version = "0.9.1"
1818
authors = ["Gal Ben David <gal@intsights.com>"]
1919
description = "A Git Repository Secrets Scanner written in Rust"
2020
readme = "README.md"

src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ mod git_repository_scanner;
22
mod rules_manager;
33

44
use parking_lot::Mutex;
5+
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
56
use pyo3::exceptions;
67
use pyo3::prelude::*;
78
use pyo3::types::PyBytes;
@@ -242,7 +243,7 @@ impl GitRepositoryScanner {
242243
from_timestamp: Option<i64>,
243244
) -> PyResult<Py<PyAny>> {
244245
let mut repository_full_path = PathBuf::from(repository_path);
245-
repository_full_path.push(url.split('/').last().unwrap_or(""));
246+
repository_full_path.push(utf8_percent_encode(url, NON_ALPHANUMERIC).to_string());
246247

247248
let mut builder = git2::build::RepoBuilder::new();
248249
builder.bare(true);
@@ -253,7 +254,7 @@ impl GitRepositoryScanner {
253254
let matches = Arc::new(Mutex::new(Vec::<HashMap<&str, String>>::with_capacity(10000)));
254255
match git_repository_scanner::scan_repository(
255256
&py,
256-
repository_path,
257+
&repository_full_path.to_string_lossy(),
257258
branch_glob_pattern.unwrap_or("*"),
258259
from_timestamp.unwrap_or(0),
259260
&self.rules_manager,

0 commit comments

Comments
 (0)