pep8/mypy

This commit is contained in:
Willi Ballenthin
2022-06-06 13:47:17 -06:00
parent afc2953538
commit 59e0518e6d
4 changed files with 9 additions and 9 deletions

View File

@@ -11,8 +11,9 @@ import collections
import tabulate
import capa.render.utils as rutils
import capa.render.result_document as rd
import capa.features.freeze as frz
import capa.render.result_document as rd
import capa.features.freeze.features as frzf
from capa.rules import RuleSet
from capa.engine import MatchResults
from capa.render.utils import StringIO
@@ -60,8 +61,8 @@ def find_subrule_matches(doc: rd.ResultDocument):
for child in node.children:
rec(child)
elif isinstance(node, rd.FeatureNode) and isinstance(node.feature, frz.features.MatchFeature):
matches.add(node.node.feature.match)
elif isinstance(node, rd.FeatureNode) and isinstance(node.feature, frzf.MatchFeature):
matches.add(node.feature.match)
for rule in rutils.capability_rules(doc):
for address, node in rule.matches:

View File

@@ -5,9 +5,9 @@
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and limitations under the License.
import capa.render.result_document as rd
from capa.rules import RuleSet
from capa.engine import MatchResults
import capa.render.result_document as rd
def render(meta, rules: RuleSet, capabilities: MatchResults) -> str:

View File

@@ -7,7 +7,7 @@
# See the License for the specific language governing permissions and limitations under the License.
import io
from typing import Iterator, Union
from typing import Union, Iterator
import termcolor
@@ -41,9 +41,7 @@ def format_parts_id(data: Union[rd.AttackSpec, rd.MBCSpec]):
def capability_rules(doc: rd.ResultDocument) -> Iterator[rd.RuleMatches]:
"""enumerate the rules in (namespace, name) order that are 'capability' rules (not lib/subscope/disposition/etc)."""
for (_, _, rule) in sorted(
map(lambda rule: (rule.meta.namespace or "", rule.meta.name, rule), doc.rules.values())
):
for (_, _, rule) in sorted(map(lambda rule: (rule.meta.namespace or "", rule.meta.name, rule), doc.rules.values())):
if rule.meta.lib:
continue
if rule.meta.is_subscope_rule:

View File

@@ -23,14 +23,15 @@ Unless required by applicable law or agreed to in writing, software distributed
See the License for the specific language governing permissions and limitations under the License.
"""
from tarfile import FIFOTYPE
import tabulate
import dnfile.mdtable
import capa.rules
import capa.render.utils as rutils
import capa.features.freeze as frz
import capa.render.result_document
import capa.render.result_document as rd
import capa.features.freeze as frz
from capa.rules import RuleSet
from capa.engine import MatchResults