Skip to content

Commit e6591dc

Browse files
authored
Merge pull request #130 from rowingdude/v3.0.5
V3.0.5
2 parents a965cf9 + 4c12452 commit e6591dc

18 files changed

+1556
-15
lines changed

CHANGES.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11

2-
# AnalyzeMFT Change Log
2+
## Versions 3.0.2 and 3.0.3 (2024-09-04)
33

4-
This document lists the changes and version history for the AnalyzeMFT script and component scripts.
4+
### Changes
5+
- Brought back XML, JSON outputs
6+
- Added optional Excel output (requires openpyxl)
7+
- Restored type hints
8+
- Tinkered a little more with the attribute specific functions
9+
10+
### Fixes
11+
- Fixed a minor CSV formatting error where path names weren't being correctly parsed.
12+
13+
### To do
14+
- Fix the root path file name - currently the parser picks up everything after the `C:\`, I'd like to have the target drive letter also
15+
- Add verbose and very verbose output to accompany debug
16+
- Create tests for each class, module, and output type.
17+
- Finish migrating the `MFTRecord.To_CSV()` functionality to `FileWriters.WriteCSV()`
18+
- Should I be making a new module called `Output_Format`, thus invoking items like `Output_Format.TO_CSV()` .. seems like a lot of work for marginal gain.
19+
- Better utilize Python built-ins like `@dataclass` and `@staticmethod` on items that would be equivalent to C's `enums` and `structs`.
20+
- Sort out the documentation and steps to implement a SQLite or PostgreSQL database and use that as an output format.
21+
22+
### Big thanks!
23+
To my wife, Jessica, for giving me the motivation to pick this project back up and get it back to a stable, working state. Also thank you to the Reddit Arduino community for helping me consolidate my thoughts on this and some other projects.
524

625
## Version 3.0.1 (2024-09-03)
726

analyzeMFT.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import asyncio
21
import sys
2+
import asyncio
33
from src.analyzeMFT.cli import main
44

55
if __name__ == "__main__":
66
if sys.platform == "win32":
7-
# This sets the event loop policy to use the ProactorEventLoop on Windows
8-
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
9-
7+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
108
asyncio.run(main())

requirements-dev.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pytest
2+
pytest-cov
3+
pytest-mock
4+
pytest-asyncio

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
openpyxl==3.0.10

src/analyzeMFT/__init__.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
from .windows_time import WindowsTime
22
from .mft_record import MftRecord
33
from .mft_analyzer import MftAnalyzer
4-
from .constants import VERSION
4+
from .file_writers import FileWriters
5+
from .constants import VERSION, CSV_HEADER
6+
from .cli import main
57

6-
__all__ = ['WindowsTime', 'MftRecord', 'MftAnalyzer', 'VERSION']
8+
__all__ = [
9+
'WindowsTime',
10+
'MftRecord',
11+
'MftAnalyzer',
12+
'FileWriters',
13+
'VERSION',
14+
'CSV_HEADER',
15+
'main'
16+
]
17+
18+
__version__ = VERSION

src/analyzeMFT/cli.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,35 @@ async def main():
3636

3737
(options, args) = parser.parse_args()
3838

39-
if not options.filename or not options.output_file:
39+
if not options.filename:
4040
parser.print_help()
41+
print("\nError: No input file specified. Use -f or --file to specify an MFT file.")
42+
sys.exit(1)
43+
44+
if not options.output_file:
45+
parser.print_help()
46+
print("\nError: No output file specified. Use -o or --output to specify an output file.")
4147
sys.exit(1)
4248

4349
if not options.export_format:
4450
options.export_format = "csv" # Default to CSV if no format specified
4551

46-
analyzer = MftAnalyzer(options.filename, options.output_file, options.debug, options.compute_hashes, options.export_format)
47-
await analyzer.analyze()
48-
print(f"Analysis complete. Results written to {options.output_file}")
52+
try:
53+
analyzer = MftAnalyzer(options.filename, options.output_file, options.debug, options.compute_hashes, options.export_format)
54+
await analyzer.analyze()
55+
print(f"Analysis complete. Results written to {options.output_file}")
56+
except FileNotFoundError:
57+
print(f"Error: The file '{options.filename}' was not found.")
58+
sys.exit(1)
59+
except PermissionError:
60+
print(f"Error: Permission denied when trying to read '{options.filename}' or write to '{options.output_file}'.")
61+
sys.exit(1)
62+
except Exception as e:
63+
print(f"An unexpected error occurred: {str(e)}")
64+
if options.debug:
65+
import traceback
66+
traceback.print_exc()
67+
sys.exit(1)
4968

5069
if __name__ == "__main__":
5170
asyncio.run(main())

src/analyzeMFT/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = '3.1'
1+
VERSION = '3.0.5'
22

33
# File Record Flags
44
FILE_RECORD_IN_USE = 0x0001

src/analyzeMFT/mft_record.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import zlib
55
from .constants import *
66
from .windows_time import WindowsTime
7-
from typing import Dict, Set, List, Optional, Any
7+
from typing import Dict, Set, List, Optional, Any,Union
88

99

1010
class MftRecord:

tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)