mondoohq / cnquery

open source, cloud-native, graph-based asset inventory
https://cnquery.io
Other
305 stars 20 forks source link

`os.uptime` returns a strange json value on Linux #1326

Open czunker opened 1 year ago

czunker commented 1 year ago

Describe the bug The value returned from os.uptime results in a failure parsing it in the UI.

It seems somehow to be no valid format:

cnquery run -c "os.uptime" --config invalid -j; echo ""; uptime; cnquery run -c "os.uptime" --config invalid                                                        
→ no provider specified, defaulting to local.
  Use --help for a list of available providers.
! could not load configuration file invalid
→ discover related assets for 1 asset(s)
→ resolved assets resolved-assets=1
[{"os.uptime":"0000-01-03T01:13:28+00:53"}]

# linux uptime:
 12:11:18 up 2 days, 20 min,  1 user,  load average: 0,73, 1,34, 1,87

# w/o json
→ no provider specified, defaulting to local.
  Use --help for a list of available providers.
! could not load configuration file invalid
→ discover related assets for 1 asset(s)
→ resolved assets resolved-assets=1
os.uptime: 2 days 20 minutes 

I do not see how "2 days 20 minutes" translates to "0000-01-03T01:13:28" and also the timezone looks wrong to me: "+00:53"

To Reproduce Steps to reproduce the behavior:

  1. Run above commands on a Linux system
  2. Note the error

Expected behavior I would expect a valid timezone and an obvious value.

Additional context Not sure how this looks like on Mac or Windows.

chris-rock commented 1 year ago

We need to implement a special handling for duration. Right now the raw date is exported which is wrong. MQL uses special internal handling to calculate date and duration with the same type.