Skip to content
Open
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
1 change: 1 addition & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
homogenous
ccompiler
56 changes: 47 additions & 9 deletions src/demystify/demystify.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@

from .denylist_template import denylist_template
from .libs import version
from .libs.AnalysisResultsClass import AnalysisResults
from .libs.DemystifyAnalysisClass import AnalysisError, DemystifyAnalysis
from .libs.HandleDenylistClass import HandleDenylist
from .libs.IdentifyDatabase import IdentifyDB
from .libs.outputhandlers import noclasshtml as nc

# Custom output handlers
from .libs.outputhandlers.htmloutputclass import FormatAnalysisHTMLOutput
Expand Down Expand Up @@ -109,7 +111,12 @@ def _handle_denylist_config() -> tuple:


def handle_output(
analysis_results, txtout=False, rogues=False, heroes=False, rogueconfig=None
analysis_results: AnalysisResults,
txtout: bool = False,
legacy: bool = False,
rogues: bool = False,
heroes: bool = False,
rogueconfig: ConfigParser = None,
):
"""Handle output from the analysis.

Expand All @@ -132,19 +139,29 @@ def handle_output(
logger.info("outputting text report")
textoutput = FormatAnalysisTextOutput(analysis_results)
print(textoutput.printTextResults())
elif rogues is True:
return

if rogues is True:
logger.info(ROGUES_TEXT)
rogueoutput = rogueoutputclass(analysis_results, rogueconfig)
rogueoutput.printTextResults()
elif heroes is True:
return

if heroes is True:
logger.info(ROGUES_TEXT)
rogueoutput = rogueoutputclass(analysis_results, rogueconfig, heroes)
rogueoutput.printTextResults()
else:
return

if legacy:
logger.info("Outputting HTML report")
htmloutput = FormatAnalysisHTMLOutput(analysis_results)
print(htmloutput.printHTMLResults())

else:
htm = nc.html(analysis_results)
print(htm)


def analysis_from_database(
database_connection=sqlite3.Connection,
Expand Down Expand Up @@ -216,9 +233,14 @@ def analysis_from_csv(
database_connection = sqlitefid.identify_and_process_input(format_report)
if not database_connection:
logger.error("no database result: %s", database_connection)
return "ensure that the input file is one of the supported DROID CSV, or Siegfried YAML types."
logger.error(
"ensure that the input file is one of the supported DROID CSV, or Siegfried YAML types."
)
sys.exit(1)
if not analyze:
logger.error("analysis flag is not set: %s", analyze)
logger.warning(
"analysis flag is not set: '%s' only a database will be created", analyze
)
return
if not label:
label = get_report_label(format_report)
Expand Down Expand Up @@ -262,10 +284,21 @@ def main():
default=False,
)
parser.add_argument(
"--txt", "--text", help="Output text instead of HTML", action="store_true"
"--txt",
"--text",
help="Output text instead of HTML",
action="store_true",
)
parser.add_argument(
"--denylist", help="Use configured denylist", action="store_true"
"--legacy",
"-l",
help="Output legacy HTML",
action="store_true",
)
parser.add_argument(
"--denylist",
help="Use configured denylist",
action="store_true",
)
parser.add_argument(
"--rogues",
Expand Down Expand Up @@ -341,7 +374,12 @@ def main():
)
if analysis:
handle_output(
analysis.analysis_results, args.txt, args.rogues, args.heroes, rogueconfig
analysis_results=analysis.analysis_results,
txtout=args.txt,
legacy=args.legacy,
rogues=args.rogues,
heroes=args.heroes,
rogueconfig=rogueconfig,
)
output_time(start_time)
logger.info("demystify: ...analysis complete")
Expand Down
6 changes: 3 additions & 3 deletions src/demystify/i18n/internationalstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AnalysisStringsEN:
REPORT_TOOL = "Analysis Tool"
NAMESPACES = "Namespaces Used"

REPORT_MORE_INFORMATION = "More Detail:"
REPORT_MORE_INFORMATION = "More Detail"

COUNT_TEXT = " Counts are shown for each entry in round () brackets."

Expand Down Expand Up @@ -315,8 +315,8 @@ class AnalysisStringsEN:
)

SUMMARY_DESC_EXTENSION_ID = (
'Files that can only be identified by their extension (e.g. ".DOC" might be a Microsoft Word '
'file, ".MP3" might be an audio file) This is a sub-set of the "Total unidentified files".'
"Files that can only be identified by their extension (e.g. '.DOC' might be a Microsoft Word "
"file, '.MP3' might be an audio file) This is a sub-set of the 'Total unidentified files'."
)

SUMMARY_DESC_EXTENSION_MISMATCH = "This is the total number of cases where the extension used does not match with the file signature."
Expand Down
2 changes: 1 addition & 1 deletion src/demystify/libs/DemystifyAnalysisClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def list_duplicate_files_from_hash(self):
# There is a potential or empty checksums in the database,
# either through incorrectly writing the data or rogue
# datasets, avoid processing and outputting those here.
if checksum == "":
if checksum in ("", None):
continue

self.analysis_results.totalHASHduplicates = (
Expand Down
Loading
Loading