insights-core icon indicating copy to clipboard operation
insights-core copied to clipboard

ls_parser throws exception "ValueError: invalid literal for int() with base 10: '?' for line result["size"] = int(size)"

Open huali027 opened this issue 2 years ago • 0 comments

It is found with the spec "ls -lZ /var/lib/rsyslog", the output of the spec is

-rw------- 1 root root ? 125 Dec 11 01:04 imjournal.state

The archive is from RHEL8 host, but the selinux context does not display, it shows as "?", so the workflow of the following code block is messy due to the "?":

            if parts[1][0].isdigit():
                # We have to split the line again to see if this is a RHEL8
                # selinux stanza. This assumes that the context section will
                # always have at least two pieces separated by ':'.
                if ":" in line.split()[4]:
                    rest = parse_rhel8_selinux(parts[1:])
                else:
                    rest = parse_non_selinux(parts[1:])
            else:
                rest = parse_selinux(parts[1:])

It enters the parse_non_selinux function since there is no colon in the SELinux context.

huali027 avatar Dec 13 '22 09:12 huali027