Skip to content

Fix network-ops tool wrapper bugs from test analysis#72

Merged
mkultraWasHere merged 4 commits into
mainfrom
nops-improvement
Jul 7, 2026
Merged

Fix network-ops tool wrapper bugs from test analysis#72
mkultraWasHere merged 4 commits into
mainfrom
nops-improvement

Conversation

@mkultraWasHere

Copy link
Copy Markdown
Contributor

Fixes confirmed tool bugs surfaced by cross-session error analysis of three network-ops agent runs (482 tool calls, 62 errors).

Fixed

  • smb_list_files no longer silently discards valid directory listings when smbclient exits non-zero due to inaccessible subdirectories — partial output is now preserved with warnings appended
  • netexec_smb_enum_group_members and netexec_ldap_enum_group_members no longer break when passed multiple groups — netexec --groups only accepts one value, so groups are now queried individually and results joined
  • SharpView._execute no longer breaks arguments containing spaces (e.g. -Domain "my domain.local") — replaced str.split() with shlex.split()
  • Impacket script discovery no longer crashes when PATH entries are bash wrapper scripts instead of real Python — _get_impacket_script_path() now detects shell wrappers and follows them to the actual script directory

Notes

  • The impacket version mismatch on the Kali test box (system 0.10.0 vs uv-cached 0.13.0) is a runtime packaging issue, not addressable from the wrapper
  • session_analysis_cross_session.md is intentionally not included in this PR

…nalysis

Address confirmed tool bugs from three test sessions (482 total calls,
62 errors). Fixes silent data loss in SMB listing, broken multi-group
netexec queries, naive arg splitting in SharpView, and impacket script
discovery failing on shell wrapper scripts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request hardens several network-ops tool wrappers to better handle real-world CLI quirks observed during cross-session error analysis, improving robustness of SMB enumeration, NetExec group queries, SharpView argument parsing, and Impacket script discovery.

Changes:

  • Preserve partial smbclient recursive listing output even when the process exits non-zero, and surface warnings.
  • Query NetExec --groups one group at a time and join outputs to support multiple requested groups.
  • Fix SharpView argument parsing for quoted/space-containing arguments using shlex.split().
  • Improve Impacket script-path discovery when PATH points to shell wrapper scripts.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
capabilities/network-ops/tools/smbclient.py Reworks smb_list_files execution to preserve partial output and handle timeouts.
capabilities/network-ops/tools/sharpview.py Uses shlex.split() to correctly parse quoted SharpView argument strings.
capabilities/network-ops/tools/netexec.py Loops --groups queries per group to match NetExec CLI constraints; joins results.
capabilities/network-ops/tools/impacket.py Adds wrapper detection and PATH-following logic for Impacket script discovery.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread capabilities/network-ops/tools/smbclient.py Outdated
Comment thread capabilities/network-ops/tools/netexec.py Outdated
Comment thread capabilities/network-ops/tools/netexec.py Outdated
Comment thread capabilities/network-ops/tools/impacket.py
- Always append warning banner in smb_list_files when exit is non-zero,
  even without stderr output
- Log full exceptions server-side in netexec group queries instead of
  exposing raw exception text (may contain credentials) in tool output
- Add binary file detection to _is_python_script() for robustness

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread capabilities/network-ops/tools/smbclient.py
Comment thread capabilities/network-ops/tools/sharpview.py
Comment thread capabilities/network-ops/tools/impacket.py
- Use posix=False in shlex.split for SharpView args to preserve
  backslashes in AD-style domain\user arguments
- Fix docstring for _extract_real_path_from_wrapper to match return type

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread capabilities/network-ops/tools/sharpview.py Outdated
Comment thread capabilities/network-ops/tools/impacket.py
- Rename generator variable to avoid shadowing typing import in sharpview
- Strip quotes from extracted script paths in impacket wrapper parser

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment on lines +192 to +195
# netexec --groups only accepts one group at a time, so we loop
# and join results when multiple groups are requested.
results: list[str] = []
for group in groups:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refuted. The original code would have produced args=["--groups"] with no group value on empty input, which netexec rejects. Our change doesn't introduce new silent-failure behavior. Adding empty-list validation is not a pattern used elsewhere in this codebase's tool methods.

Comment on lines +340 to +343
# netexec --groups only accepts one group at a time, so we loop
# and join results when multiple groups are requested.
results: list[str] = []
for group in groups:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refuted. Same reasoning as SMB variant above.

Comment on lines +13 to +14
def _is_python_script(path: Path) -> bool:
"""Check if a file is a real Python script (not a shell wrapper or binary)."""

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refuted. The docstring already says "not a shell wrapper or binary" which accurately describes the exclusion logic. It's a private helper with a single caller — further rewording adds no value.

@mkultraWasHere mkultraWasHere merged commit 4f5b0c6 into main Jul 7, 2026
5 checks passed
mkultraWasHere added a commit that referenced this pull request Jul 7, 2026
Version bump for tool wrapper bug fixes merged in #72.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants