Skip to content

Add an SSG module for interacting with SSG#12

Merged
dLobatog merged 1 commit intoOpenSCAP:masterfrom
akofink:add-ssg
Sep 13, 2019
Merged

Add an SSG module for interacting with SSG#12
dLobatog merged 1 commit intoOpenSCAP:masterfrom
akofink:add-ssg

Conversation

@akofink
Copy link
Copy Markdown
Collaborator

@akofink akofink commented Sep 6, 2019

Policies and Rules come from the SCAP Security Guide, generated from
https://github.com/ComplianceAsCode/content. This adds rake tasks to
download and unarchive released versions of SSG for a given application,
and a shortcut rake task for all the RHEL SSG content.

rake ssg:sync_rhel
Archive:  scap-security-guide-0.1.46.zip
  inflating: scap-security-guide-0.1.46/ssg-rhel6-ds.xml  
  inflating: scap-security-guide-0.1.46/ssg-rhel7-ds.xml  
  inflating: scap-security-guide-0.1.46/ssg-rhel8-ds.xml

Todo:

  • docs
  • tests

It seems weird to namespace parts of this under OpenscapParser, such as the Downloader and Unarchiver, since they do no parsing of SCAP content.

@dLobatog I'd like a sanity check here before I go further with tests and docs. I plan on submitting another PR for any additional parsing code we need.

Signed-off-by: Andrew Kofink akofink@redhat.com

@akofink akofink requested a review from dLobatog September 6, 2019 19:40
Comment thread Rakefile Outdated
Comment thread lib/ssg/downloader.rb Outdated
Comment thread lib/ssg.rb
require 'ssg/downloader'
require 'ssg/unarchiver'

module Ssg
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I've tried to design these two classes so that the methods are short and well-named so it's easy to understand what is happening without a bunch of comments.

Comment thread lib/ssg/downloader.rb

def download_urls
get_json(LATEST_RELEASE_URI).dig('assets').map do |asset|
asset.dig('browser_download_url')
Copy link
Copy Markdown
Collaborator Author

@akofink akofink Sep 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is coupled to GitHub's releases api, unfortunately. If they change the structure of the response, we'll have to update this method. It's essentially:

http https://api.github.com/repos/ComplianceAsCode/content/releases/latest | jq '.assets[] | .browser_download_url'

Comment thread lib/ssg/downloader.rb
# Downloads SCAP datastreams from the SCAP Security Guide
# https://github.com/ComplianceAsCode/content
class Downloader
RELEASES_API = 'https://api.github.com/repos'\
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How official source is this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look good :( (from #openscap on irc.devel.rh):

13:00   akofink ╡ o/ Hi - how reliably do the releases at https://github.com/ComplianceAsCode/content/releases match what is packaged and shipped as RPMs to RHEL?
13:01         ⤷ ╡ like, RHEL7 has scap-security-guide-0.1.43-13.el7.noarch - are the datastreams provided guaranteed to match tag v0.1.43 on github?
13:11   ascheel ╡ akofink: (I don't work on this team any more, and everyone who still does is UTC+2) -- I think dist-git is your friend here.
13:13   ascheel ╡ akofink: `rhpkg clone scap-security-guide` -- 7.7 has what you see there, 7.8 has a rebase to v0.1.46. There's a number of patches (~28) which have been picked on top of 0.1.43 tarball.
13:14   akofink ╡ hrmm, okay :/ it seems more complicated than I expected
13:14   ascheel ╡ akofink: What are you looking for in particular while I have it up?
13:15   akofink ╡ I'm writing a thing to download and extract certain datastreams of specific versions of the SSG, and we'd like to sync the SSG provided to RHEL6, 7, and 8. It seems like the only way to really do that is to look at the RHEL package repos
13:16         ⤷ ╡ https://github.com/dLobatog/openscap_parser/pull/12 if you're interested
13:16         ⤷ ╡ (the openscap ffi gem has memory leaks last we checked)
13:17   ascheel ╡ Yeah, sorry. The RHEL packaging process kinda hinders SSG here.
13:17   akofink ╡ thanks for the pointers though :)
13:18   ascheel ╡ akofink: Yeah looks like they've picked ~66 commits on top of that tag.
13:18   akofink ╡ geez

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also sent an email to scap-internal-list with the subject "Hosted SSG - A Use Case for cloud.redhat.com" if you're interested in following the discussion there.

Copy link
Copy Markdown
Contributor

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akofink Thanks! It looks good to me, I was able to download and test it successfully.

I would not really do any testing since you're just calling libraries to download/unarchive. I wonder as you said though, if this is part of openscap_parser or should it rather be a openscap_ssg_downloader - I don't mind keeping it here as it's definitely handy and would help all users of openscap_parser, but IMO this should be another library. Your call.

Comment thread Rakefile Outdated
Comment thread Rakefile Outdated
@akofink
Copy link
Copy Markdown
Collaborator Author

akofink commented Sep 10, 2019

Added a Readme. @dLobatog no tests, really?

@akofink akofink marked this pull request as ready for review September 10, 2019 17:09
Policies and Rules come from the SCAP Security Guide, generated from
https://github.com/ComplianceAsCode/content. This adds rake tasks to
download and unarchive released versions of SSG for a given application,
and a shortcut rake task for all the RHEL SSG content.

Signed-off-by: Andrew Kofink <akofink@redhat.com>
@akofink
Copy link
Copy Markdown
Collaborator Author

akofink commented Sep 12, 2019

Added a couple simple tests. This should be ready for final review

Copy link
Copy Markdown
Contributor

@dLobatog dLobatog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's awesome @akofink , thank you! Let's get this in so we can run it already 😄

@dLobatog dLobatog merged commit c8be36b into OpenSCAP:master Sep 13, 2019
@akofink akofink deleted the add-ssg branch September 13, 2019 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants