Skip to content

Commit

Permalink
Merged concurrent work on database scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
akenion committed Sep 23, 2024
1 parent b35334b commit 00663c4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
11 changes: 9 additions & 2 deletions wordfence/cli/dbscan/dbscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from wordfence.wordpress.site import WordpressLocator, \
WordpressSite
from wordfence.wordpress.exceptions import WordpressException
from wordfence.intel.database_rules import DatabaseRuleSet
from wordfence.intel.database_rules import DatabaseRuleSet, load_database_rules
from wordfence.databasescanning.scanner import DatabaseScanner
from wordfence.util.validation import ListValidator, DictionaryValidator, \
OptionalValueValidator
Expand Down Expand Up @@ -142,8 +142,15 @@ def _get_databases(self) -> List[WordpressDatabase]:
databases.append(database)
return databases

def invoke(self) -> int:
def _load_rules(self) -> DatabaseRuleSet:
rule_set = DatabaseRuleSet()
for rules_file in self.config.rules_file:
load_database_rules(rules_file, rule_set)
return rule_set

def invoke(self) -> int:
rule_set = self._load_rules()
print(repr(vars((rule_set.rules[1]))))
scanner = DatabaseScanner(rule_set)
for database in self._get_databases():
scanner.scan(database)
Expand Down
11 changes: 10 additions & 1 deletion wordfence/cli/dbscan/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,16 @@
"argument_type": "FLAG",
"default": True,
"category": "Site Location"
}
},
"rules-file": {
"short_name": "R",
"description": "Path to a JSON file containing scanning rules",
"context": "ALL",
"argument_type": "OPTION_REPEATABLE",
"meta": {
"accepts_file": True
}
}
}

examples = [
Expand Down

0 comments on commit 00663c4

Please sign in to comment.