docker-forensics icon indicating copy to clipboard operation
docker-forensics copied to clipboard

TypeError: unsupported format string passed to NoneType.__format__ / statx

Open yarox24 opened this issue 11 months ago • 3 comments

https://github.com/att/docker-forensics/blob/d50c444d59855e46ec5778942d0cad00cf722c75/mac-robber.py#L131

Traceback:

(... more data ...)
0|/etc/ld.so.conf|786616|-rw-rw-r--|0|0|34|1734440793.017330|1608116695.000000|1697471167.713379|1697471167.713379
0|/etc/rsyslog.conf|786654|-rw-rw-r--|0|0|1382|1734436377.488000|1640302499.000000|1697471167.721380|1697471167.721380
0|/etc/inputrc|786609|-rw-rw-r--|0|0|1748|1734679563.963715|1641486414.000000|1697471167.709378|1697471167.709378
0|/etc/magic.mime|786629|-rw-rw-r--|0|0|111|1697522640.364750|1648141629.000000|1697471167.713379|1697471167.713379
0|/etc/ethertypes|786596|-rw-rw-r--|0|0|1816|1577407331.000000|1577407331.000000|1697471167.705378|1697471167.705378
Traceback (most recent call last):
  File "/root/docker/mac-robber/orig/mac-robber.py", line 221, in <module>
    outstr = process_item(dirpath, filename)
  File "/root/docker/mac-robber/orig/mac-robber.py", line 131, in process_item
    btime = "{:17.6f}".format(statx.statx(fname).btime)
TypeError: unsupported format string passed to NoneType.__format__

I installed library: https://pypi.org/project/pystatx/ (Version: 0.1)

and there is following error in this underlying library:

image

Problem seems to be related with links: image

But stat is working on this link: image

I'm writing here as there is only single version of this library, which may be no longer maintained.

My dirty solution: image

yarox24 avatar Dec 20 '24 07:12 yarox24

I also linked this issue on library repo: https://github.com/ckarageorgkaneen/pystatx/issues/5

yarox24 avatar Dec 20 '24 07:12 yarox24

For the moment, I've incorporated your workaround. Thanx for bringing this to my attention.

clausing avatar Dec 30 '24 16:12 clausing

Looking at the the source None is the default for btime when the field is not present in the return value picked up by python. I gather this means the under lying call to statx doesn't include it in the return. errno is not being check by pystax so the call could be erroring out. By default pystatx tells statx to resolve symlinks. Which means its trying to stat what the symlink points to. I created fork with proper error handling https://github.com/reporter123/pystatx it also requires python 3.6+ as it uses an f string instead of calling format.

reporter123 avatar Jan 11 '25 22:01 reporter123