Skip to content

Commit

Permalink
warning fix (#571)
Browse files Browse the repository at this point in the history
  • Loading branch information
babenek authored Jun 25, 2024
1 parent f9ec85a commit 4892be9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
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

0 comments on commit 4892be9

Please sign in to comment.