Skip to content
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
38 changes: 0 additions & 38 deletions deepsecrets/core/helpers/variable_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
from deepsecrets.core.helpers.entropy import EntropyHelper
from deepsecrets.core.model.rules.variable_scoring import VariableScoringRule
from deepsecrets.core.model.semantic import Context, Variable
from nostril import nonsense

# func = generate_nonsense_detector(min_score=8.1)


@dataclass
Expand Down Expand Up @@ -57,41 +54,6 @@ def calculate_entropy_score(self, entropy: float) -> float:

return 40

def _is_nonsense(self, token: str) -> float:
if len(token) <= 6:
return 0

is_nonsense = True
try:
is_nonsense = nonsense(token)
except ValueError:
pass

return 1 if is_nonsense is True else 0

def calculate_nonsense_value_score(self, parts: List[str], normalized: str) -> float:
if len(normalized) > 300:
return 1 # obviously

len_checks = 0
applicable_parts = [t for t in parts if len(t) > 6]
scores = 0

for part in applicable_parts:
try:
scores += self._is_nonsense(part)
len_checks += 1
except Exception:
pass

normalized_string_score = 0
if len(normalized) > 6:
normalized_string_score = self._is_nonsense(normalized)

if len_checks == 0:
return 0
return ((scores / len_checks) + normalized_string_score) / 2

def evaluate(self, variable: Union[Variable | Context]) -> EvaluationResult:
context = variable.context if isinstance(variable, Variable) else variable

Expand Down
84 changes: 10 additions & 74 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ dependencies = [
"sarif-om == 1.0.4",
"jschema-to-python == 1.2.3",
"rich (==15.0.0)",
"nostril @ git+https://github.com/casics/nostril.git",
]

[project.urls]
Expand Down
Loading