fleetdm / fleet

Open-source platform for IT, security, and infrastructure teams. (Linux, macOS, Chrome, Windows, cloud, data center)
https://fleetdm.com
Other
3.01k stars 418 forks source link

Output of `fleetctl get mdm-command-results` is not aligned at the end of the table #12128

Closed mna closed 1 year ago

mna commented 1 year ago

Fleet version: (head to the "My account" page in the Fleet UI or run fleetctl --version)

ef061b1

Operating system: (e.g. macOS 11.2.3)

Linux (likely the same on macOS and Windows)


🧑‍💻  Expected behavior

From this discussion: https://github.com/fleetdm/fleet/pull/12006#discussion_r1214391023

Properly aligned end of table, like it is in fleetctl get mdm-commands, e.g. the table output at https://fleetdm.com/docs/using-fleet/mdm-commands#list-recent-commands.

💥  Actual behavior

Misaligned end of table, e.g. the table output at https://fleetdm.com/docs/using-fleet/mdm-commands#step-3-run-the-command

👣 Reproduction steps

Run fleetctl get mdm-command-results with a real mdm command id, chances are the end of the table will be misaligned if it does have an XML result (the RESULTS column).

More info

I think this is either a bug with our tab-based table generating third-party package (github.com/olekukonko/tablewriter) , or maybe it's just that the results XML contains some tabs and that doesn't play nice with the alignment logic (if so we could probably just do a string replace of tabs => space).

xpkoala commented 1 year ago

Fixed!

mna commented 1 year ago

@xpkoala

Fixed!

It may depend on the command ID (and maybe even the OS/terminal), but for me it still shows as unaligned, e.g. given this command id on dogfood (I garbled the response just to be safe but the ID is the correct one if you want to try it):

$ fleetctl get mdm-command-results -id 333af7f8-a9a4-4f62-bfb2-f7488fbade21
+--------------------------------------+----------------------+----------------+--------------+---------------------+-------------------------------------------------------+
|                  ID                  |         TIME         |      TYPE      |    STATUS    |      HOSTNAME       |                        RESULTS                        |
+--------------------------------------+----------------------+----------------+--------------+---------------------+-------------------------------------------------------+
| 333af7f8-a9a4-4f62-bfb2-f7488fbade21 | 2023-04-04T21:29:29Z | InstallProfile | Acknowledged | xyz-macbook-air.lan | <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE      |
|                                      |                      |                |              |                     | plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"            |
|                                      |                      |                |              |                     | "http://www.apple.com/DTDs/PropertyList-1.0.dtd">     |
|                                      |                      |                |              |                     | <plist version="1.0"> <dict>  <key>CommandUUID</key>   |
|                                      |                      |                |              |                     |   <string>333af7f8-a9a4-4f62-bfb2-f7488fbade21</string> |
|                                      |                      |                |              |                     |   <key>Status</key>                                     |
|                                      |                      |                |              |                     |   <string>Acknowledged</string>   <key>UDID</key>         |
|                                      |                      |                |              |                     |   <string>ZZZZZZZZ-ZZZZ-ZZZZ-ZZZZ-ZZZZZZZZZZZZ</string> |
|                                      |                      |                |              |                     | </dict> </plist>                                      |
+--------------------------------------+----------------------+----------------+--------------+---------------------+-------------------------------------------------------+
xpkoala commented 1 year ago

@mna You are correct, apologies. It looks like I originally just poked the mdm-commands command which was returning properly formatted tables. After supplying an id I reproduced the formatting issue you posted above. I just grabbed this fix, tested again and we are looking much better.

image.png

mna commented 1 year ago

It looks like I originally just poked the mdm-commands command which was returning properly formatted tables.

Ah yeah that's probably it! Thanks!

fleet-release commented 1 year ago

Aligned table ends, Fleet commands clear as glass, City in the clouds.