utils package¶
Submodules¶
utils.util module¶
- class credsweeper.utils.util.DiffRowData(line_type, line_numb, line)[source]¶
Bases:
objectClass for keeping data of diff row.
- class credsweeper.utils.util.Util[source]¶
Bases:
objectClass that contains different useful methods.
- classmethod get_shannon_entropy(data, iterator)[source]¶
Borrowed from http://blog.dkbza.org/2007/05/scanning-data-for-entropy-anomalies.html.
- Return type
- classmethod patch2files_diff(raw_patch, change_type)[source]¶
Generate files changes from patch for added or deleted filepaths.
- Parameters
- Return type
- Returns
return dict with
{file paths: list of file row changes}, where elements of list of file row changes represented as:{ "old": line number before diff, "new": line number after diff, "line": line text, "hunk": diff hunk number }
- classmethod preprocess_file_diff(changes)[source]¶
Generate changed file rows from diff data with changed lines (e.g. marked + or - in diff).
- Parameters
- Return type
- Returns
diff rows data with as list of row change type, line number, row content
- classmethod read_file(path, encodings=('utf8', 'utf16', 'latin_1'))[source]¶
Read the file content using different encodings.
Try to read the contents of the file according to the list of encodings “encodings” as soon as reading occurs without any exceptions, the data is returned in the current encoding