From ef6f151f4b230a501aa84674d851510d3e15447a Mon Sep 17 00:00:00 2001
From: Hulto <7121375+hulto@users.noreply.github.com>
Date: Wed, 15 Jan 2025 02:09:20 +0000
Subject: [PATCH] Small fixes
---
docs/_docs/user-guide/eldritch.md | 6 ++++--
tavern/tomes/netstat/main.eldritch | 14 +++++++++++---
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/docs/_docs/user-guide/eldritch.md b/docs/_docs/user-guide/eldritch.md
index 4b452b655..08b348c96 100644
--- a/docs/_docs/user-guide/eldritch.md
+++ b/docs/_docs/user-guide/eldritch.md
@@ -293,6 +293,7 @@ This function also supports globbing with `*` for example:
```python
file.list("/home/*/.bash_history") # List all files called .bash_history in sub dirs of `/home/`
file.list("/etc/*ssh*") # List the contents of all dirs that have `ssh` in the name and all files in etc with `ssh` in the name
+file.list("\\\\127.0.0.1\\c$\\Windows\\*.yml") # List files over UNC paths
```
Each file is represented by a Dict type.
@@ -361,6 +362,7 @@ This function supports globbing with `*` for example:
```python
file.read("/home/*/.bash_history") # Read all files called .bash_history in sub dirs of `/home/`
file.read("/etc/*ssh*") # Read the contents of all files that have `ssh` in the name. Will error if a dir is found.
+file.read("\\\\127.0.0.1\\c$\\Windows\\Temp\\metadata.yml") # Read file over Windows UNC
```
### file.remove
@@ -381,9 +383,9 @@ The file.replace method finds the first string matching a regex pattern i
The file.replace_all method finds all strings matching a regex pattern in the specified file and replaces them with the value. Please consult the [Rust Regex Docs](https://rust-lang-nursery.github.io/rust-cookbook/text/regex.html) for more information on pattern matching.
-### file.tmp_file
+### file.temp_file
-`file.tmp_file(name: Option) -> str`
+`file.temp_file(name: Option) -> str`
The file.temp method returns the path of a new temporary file with a random filename or the optional filename provided as an argument.
diff --git a/tavern/tomes/netstat/main.eldritch b/tavern/tomes/netstat/main.eldritch
index 9115d8172..8c0c02f9b 100644
--- a/tavern/tomes/netstat/main.eldritch
+++ b/tavern/tomes/netstat/main.eldritch
@@ -14,6 +14,7 @@ def print_table(rows: list[list]):
row.append(rpad(c, counts[i]+2))
print("".join(row))
+
def netstat():
"""Pretty print the netstat results"""
# Faster to do this than to call process.info on each PID
@@ -22,7 +23,7 @@ def netstat():
pids[p['pid']] = p['name']
# Counts for dynamic column formating
- counts = [6,6,7,6,8]
+ counts = [6, 6, 7, 6, 8]
rows = [["PROTO", "LOCAL", "REMOTE", "STATE", "PROCESS"]]
# Loop through each net result and format the columns
for n in process.netstat():
@@ -35,16 +36,23 @@ def netstat():
remote = n.get("remote_address", "")
if remote:
fields[2] = remote + ":" + str(n.get("remote_port",))
+ else:
+ fields[2] = "???"
+
# Established = ESTAB
if fields[3] == "ESTABLISHED":
fields[3] = fields[3][:5]
+ else:
+ fields[3] = "???"
# Get proc info. "pids" will only ever be one
- if n["pids"]:
- fields += ["["+str(n["pids"][0])+"]"+pids.get(n["pids"][0])]
+ if "pid" in n:
+ if n["pid"]:
+ fields += ["["+str(n["pid"])+"]"+pids.get(n["pid"])]
rows.append(fields)
print_table(rows)
+
time.sleep(1)
netstat()