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

warning fix #571

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 16 additions & 6 deletions credsweeper/credentials/credential_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,26 @@ def purge_duplicates(self) -> int:

Returns: number of removed duplicates
"""
candidates_dict: Dict[Tuple[str, str, str, int, int, int, int, int], Candidate] = {}
candidates_dict: Dict[Tuple[str, str, str, int, int, int, int, int, int, int], Candidate] = {}
before = len(self.candidates)
for i in self.candidates:
ld = i.line_data_list[0]
candidate_key = (i.rule_name, ld.path, ld.info, ld.line_pos, ld.variable_start, ld.variable_start,
ld.value_start, ld.value_end)
candidate_key = (
i.rule_name, #
ld.path, #
ld.info, #
ld.line_pos, #
ld.variable_start, #
ld.variable_end, #
ld.separator_start, #
ld.separator_end, #
ld.value_start, #
ld.value_end)
if candidate_key in candidates_dict:
# check precisely
if candidates_dict[candidate_key].compare(i):
ld_ = candidates_dict[candidate_key].line_data_list[0]
# check precisely - compare with the values
candidate_dict = candidates_dict[candidate_key]
if not candidate_dict.compare(i):
ld_ = candidate_dict.line_data_list[0]
logger.warning(f"check {ld_.variable, ld_.value} and {ld.variable, ld.value}")
else:
candidates_dict[candidate_key] = i
Expand Down
11 changes: 9 additions & 2 deletions credsweeper/scanner/scan_type/scan_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,15 @@ def get_line_data_list(
continue
if target.offset is not None:
# the target line is a chunk of long line - offsets have to be corrected
line_data.variable_start += target.offset
line_data.variable_end += target.offset
if 0 <= line_data.variable_start:
line_data.variable_start += target.offset
if 0 <= line_data.variable_end:
line_data.variable_end += target.offset
if 0 <= line_data.separator_start:
line_data.separator_start += target.offset
if 0 <= line_data.separator_end:
line_data.separator_end += target.offset
# value positions are mandatory
line_data.value_start += target.offset
line_data.value_end += target.offset
# get the original line
Expand Down
Loading