Bug 1315369 - atomic scan generates invalid json
Summary: atomic scan generates invalid json
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: atomic
Version: 7.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Lokesh Mandvekar
QA Contact: atomic-bugs@redhat.com
URL:
Whiteboard:
Depends On: 1343939 1343944 1346942
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-03-07 14:56 UTC by Jan Černý
Modified: 2020-05-05 14:45 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-05-05 14:45:19 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Jan Černý 2016-03-07 14:56:48 UTC
Description of problem:
JSON output of atomic scan contains string "Scanning..." before the actual JSON starts, which is invalid JSON syntax.

Version-Release number of selected component (if applicable):
atomic-1.6-6.gitca1e384.el7.x86_64

How reproducible:
always

Steps to Reproduce:
1. atomic scan <ID> --json

Actual results:
JSON is preceded by "\nScanning...\n"

Expected results:
Only JSON on stdout.

Additional info:
I have found that the issue has been fixed upstream in https://github.com/projectatomic/atomic/commit/7ce96abdda930d9716e48479cb3c0cd080fe263b

Comment 2 Alex Jia 2016-03-08 03:27:13 UTC
(In reply to Jan Černý from comment #0)
> Additional info:
> I have found that the issue has been fixed upstream in
> https://github.com/projectatomic/atomic/commit/
> 7ce96abdda930d9716e48479cb3c0cd080fe263b

Yes, the patch has been backported to v1.6.

[root@dell-per630-02 atomic]# git tag --contains 7ce96ab
v1.6
v1.8

[root@dell-per630-02 atomic]# git branch
* (detached from v1.6)
  jzb-patch-1
  master

[root@dell-per630-02 atomic]# git show 7ce96ab
commit 7ce96abdda930d9716e48479cb3c0cd080fe263b
Author: Dan Walsh <dwalsh>
Date:   Mon Nov 23 08:22:35 2015 -0500

    Don't output Scanning, user knows that

diff --git a/Atomic/atomic.py b/Atomic/atomic.py
index 85312bb..a668037 100644
--- a/Atomic/atomic.py
+++ b/Atomic/atomic.py
@@ -472,7 +472,6 @@ class Atomic(object):
                                  "use) and therefore cannot be scanned.\n"
                                  .format(docker_obj))
                 sys.exit(1)
-        util.writeOut("\nScanning...\n")
         bus = dbus.SystemBus()
         try:
             oscap_d = bus.get_object(BUS_NAME, OBJECT_PATH)

Comment 3 Alex Jia 2016-03-08 03:33:00 UTC
(In reply to Alex Jia from comment #2)
> Yes, the patch has been backported to v1.6.

s/backported/cherry-pick/

Comment 4 Daniel Walsh 2016-06-03 19:56:50 UTC
Fixed in atomic-1.10

Comment 7 Daniel Walsh 2016-06-12 10:49:22 UTC
Brent please comment on this.

Comment 8 Brent Baude 2016-06-13 14:32:10 UTC
The --json switch was removed in the following commit ->

https://github.com/projectatomic/atomic/commit/6ed4994b0d6091ccfe171b9c8e48714c53a868d6

For the record, with the re-design of the scanner at that time, atomic no longer forms the JSON output that is stored in the filesystem.  This is always done by the scanners themselves.

Comment 9 Alex Jia 2016-06-14 10:11:48 UTC
(In reply to Brent Baude from comment #8)
> The --json switch was removed in the following commit ->
> 
> https://github.com/projectatomic/atomic/commit/
> 6ed4994b0d6091ccfe171b9c8e48714c53a868d6
> 
> For the record, with the re-design of the scanner at that time, atomic no
> longer forms the JSON output that is stored in the filesystem.  This is
> always done by the scanners themselves.

Brent, okay, because the --json switch has been removed, and I can't give a further testing due to bug 1343944 and 1343939, so I tend to close the bug.

Comment 10 Lokesh Mandvekar 2016-06-15 14:43:58 UTC
Brent, can we remove this bug from the advisory?

Comment 11 Brent Baude 2016-06-15 15:16:43 UTC
I dont see why not.  Do others object?

Comment 12 Lokesh Mandvekar 2016-06-15 15:19:27 UTC
Not really, just wanted to make sure :)

Comment 14 Alex Jia 2016-06-16 10:31:23 UTC
Just a record, atomic scan will put test report in *.xml and json format under the /var/lib/atomic/openscap/$date/$image_id/, I used python -m json.tool to check /var/lib/atomic/openscap/$date/$image_id/json, it's valid json format, so I tend to close the bug as VERIFIED.


Note You need to log in before you can comment on or make changes to this bug.