fox-it / dissect.target

The Dissect module tying all other Dissect modules together. It provides a programming API and command line tools which allow easy access to various data sources inside disk images or file collections (a.k.a. targets).
GNU Affero General Public License v3.0
43 stars 44 forks source link

Fixed KeyError when loading Windows targets over SMB #726

Closed Paradoxis closed 3 months ago

Paradoxis commented 3 months ago

Change various ["sysvol"] statements to .get methods as to avoid breaking SMB targets with low-privileged credentials

│                                                                                                  │
│ /home/user/.local/lib/python3.11/site-packages/dissect/target/plugins/os/windows/_os.py:82 in    │
│ add_mounts                                                                                       │
│                                                                                                  │
│    79 │   │   │   self.target.log.debug("", exc_info=e)                                          │
│    80 │   │                                                                                      │
│    81 │   │   # Fallback mount the sysvol to C: if we didn't manage to mount it to any other d   │
│ ❱  82 │   │   if operator.countOf(self.target.fs.mounts.values(), self.target.fs.mounts["sysvo   │
│    83 │   │   │   if "c:" not in self.target.fs.mounts:                                          │
│    84 │   │   │   │   self.target.log.debug("Unable to determine drive letter of sysvol, falli   │
│    85 │   │   │   │   self.target.fs.mount("c:", self.target.fs.mounts["sysvol"])                │
│                                                                                                  │
│ ╭─────────────────────────────────────── locals ────────────────────────────────────────╮        │
│ │ self = <dissect.target.plugins.os.windows._os.WindowsPlugin object at 0x7f87c488a3d0> │        │
│ ╰───────────────────────────────────────────────────────────────────────────────────────╯        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
KeyError: 'sysvol'
codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 75.01%. Comparing base (b89b12d) to head (51defd2).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #726 +/- ## ======================================= Coverage 75.01% 75.01% ======================================= Files 294 294 Lines 25016 25018 +2 ======================================= + Hits 18766 18768 +2 Misses 6250 6250 ``` | [Flag](https://app.codecov.io/gh/fox-it/dissect.target/pull/726/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fox-it) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/fox-it/dissect.target/pull/726/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fox-it) | `75.01% <100.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fox-it#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.