Skip to content

Commit

Permalink
Fixed indentation errors introduced in docstrings commit
Browse files Browse the repository at this point in the history
  • Loading branch information
malicialab committed Feb 23, 2023
1 parent b51d067 commit c3d78dc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
34 changes: 17 additions & 17 deletions avclass/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def prefix_l(self):


class Taxonomy:
"""A taxonomy of tags and generic tokens read from file"""
"""A taxonomy of tags and generic tokens read from file"""
def __init__(self, filepath):
"""Initialize and populate _tag_map from input file"""
self._tags = set() # Map tag.name | tag.path -> Tag
Expand Down Expand Up @@ -227,7 +227,7 @@ def remove_overlaps(self, l):
return out_l

def read_taxonomy(self, filepath):
"""Read taxonomy from given file"""
"""Read taxonomy from given file"""
with open(filepath, 'r') as fd:
for line in fd:
if line.startswith('#') or line == '\n':
Expand All @@ -252,7 +252,7 @@ def to_file(self, filepath):
fd.close()

class Rules:
"""A relation from one source to one or more destinations"""
"""A relation from one source to one or more destinations"""
def __init__(self, filepath):
"""Initialize rule map and read rules from input file"""
self._src_map = {} # src -> set(dst)
Expand Down Expand Up @@ -303,7 +303,7 @@ def get_dst(self, src):
return list(self._src_map.get(src, []))

def read_rules(self, filepath):
"""Read rules from given file"""
"""Read rules from given file"""
with open(filepath, 'r') as fd:
for line in fd:
if line.startswith('#') or line == '\n':
Expand Down Expand Up @@ -357,7 +357,7 @@ def expand_all_destinations(self):
self._src_map[src] = dst_l

class Tagging(Rules):
"""A rule with an unknown source and a destination in the taxonomy"""
"""A rule with an unknown source and a destination in the taxonomy"""
def __init__(self, filepath):
"""Initialize rules from input file"""
Rules.__init__(self, filepath)
Expand All @@ -372,7 +372,7 @@ def validate(self, taxonomy):
sys.stdout.write("[Tagging] %s not in taxonomy\n" % t)

class Expansion(Rules):
"""A rule where source different than destination and both in taxonomy"""
"""A rule where source different than destination and both in taxonomy"""
def __init__(self, filepath):
Rules.__init__(self, filepath)

Expand All @@ -386,7 +386,7 @@ def validate(self, taxonomy):
sys.stdout.write("[Expansion] %s not in taxonomy\n" % dst)

class AvLabels:
"""Primary class to process AV labels"""
"""Primary class to process AV labels"""
def __init__(self, tag_file, exp_file = None, tax_file = None,
av_file = None, aliasdetect=False):
"""Initialize using given files and options"""
Expand All @@ -403,7 +403,7 @@ def __init__(self, tag_file, exp_file = None, tax_file = None,

@staticmethod
def read_avs(avs_file):
"""Read AV engine set from given file"""
"""Read AV engine set from given file"""
with open(avs_file) as fd:
avs = set(map(str.strip, fd.readlines()))
sys.stderr.write("[-] Using %d AV engines in %s\n" % (len(avs),
Expand All @@ -412,13 +412,13 @@ def read_avs(avs_file):

@staticmethod
def get_sample_info_lb(vt_rep):
"""Parse sample information from basic report"""
"""Parse sample information from basic report"""
return SampleInfo(vt_rep['md5'], vt_rep['sha1'], vt_rep['sha256'],
vt_rep['av_labels'], [])

@staticmethod
def get_sample_info_vt_v2(vt_rep):
"""Parse sample information from VT v2 report"""
"""Parse sample information from VT v2 report"""
label_pairs = []
# Obtain scan results, if available
try:
Expand All @@ -443,7 +443,7 @@ def get_sample_info_vt_v2(vt_rep):

@staticmethod
def get_sample_info_vt_v3(vt_rep):
"""Parse sample information from VT v3 report"""
"""Parse sample information from VT v3 report"""
# VT file reports in APIv3 contain all info under 'data'
# but reports from VT file feed (also APIv3) don't have it
# Handle both cases silently here
Expand Down Expand Up @@ -473,13 +473,13 @@ def get_sample_info_vt_v3(vt_rep):

@staticmethod
def is_pup(tag_pairs, taxonomy):
"""Whether the sample is PUP
"""Whether the sample is PUP
Checks if highest ranked CLASS tag contains "grayware"
and is above a predefined threshold
Return:
Checks if highest ranked CLASS tag contains "grayware"
and is above a predefined threshold
Return:
True/False/None
"""
"""
threshold = 0.5
# If no tags, return false
if len(tag_pairs) < 1:
Expand All @@ -496,7 +496,7 @@ def is_pup(tag_pairs, taxonomy):

@staticmethod
def _remove_suffixes(av_name, label):
"""Returns input label without AV specific suffixes"""
"""Returns input label without AV specific suffixes"""
# Truncate after last '.'
if av_name in suffix_removal_av_set:
label = label.rsplit('.', 1)[0]
Expand Down
4 changes: 2 additions & 2 deletions avclass/labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ def main():

def parse_args():
argparser = argparse.ArgumentParser(prog='avclass',
description='Extracts tags for a set of samples.
Also calculates precision and recall if ground truth available')
description='''Extracts tags for a set of samples.
Also calculates precision and recall if ground truth available''')

argparser.add_argument('-vt', action='append',
help='file with VT reports '
Expand Down
4 changes: 2 additions & 2 deletions avclass/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,8 @@ def output(self, out_prefix):

def main():
argparser = argparse.ArgumentParser(
description='Given a .alias file from the labeler,
generates updates for the taxonomy, tagging, and expansion files.')
description='''Given a .alias file from the labeler,
generates updates for the taxonomy, tagging, and expansion files.''')

argparser.add_argument('-alias',
help='input file with alias from labeler. Mandatory.')
Expand Down

0 comments on commit c3d78dc

Please sign in to comment.