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

Indicate duplicate string #953

Merged
merged 5 commits into from
Mar 8, 2024
Merged
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
10 changes: 10 additions & 0 deletions floss/qs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import functools
import itertools
import contextlib
from collections import defaultdict
from typing import Set, Dict, List, Union, Tuple, Literal, Callable, Iterable, Optional, Sequence
from dataclasses import field, dataclass

Expand Down Expand Up @@ -651,13 +652,21 @@ def tag_strings(self, taggers: Sequence[Tagger]):
this can be overridden, if a subclass has more ways of tagging strings,
such as a PE file and code/reloc regions.
"""
string_counts = defaultdict(int)

tagged_strings: List[TaggedString] = []

for string in self.strings:
# at this moment, the list of strings contains only ExtractedStrings.
# this routine will transform them into TaggedStrings.
assert isinstance(string, ExtractedString)
tags: Set[Tag] = set()

string_counts[string.string] += 1

if string_counts[string.string] > 1:
tags.add("#duplicate")

for tagger in taggers:
tags.update(tagger(string))

Expand Down Expand Up @@ -1233,6 +1242,7 @@ def main():
tag_rules: TagRules = {
"#capa": "highlight",
"#common": "mute",
"#duplicate": "mute",
"#code": "hide",
"#reloc": "hide",
# lib strings are muted (default)
Expand Down
Loading