1
0
mirror of https://github.com/projectatomic/atomic.git synced 2026-02-05 18:45:01 +01:00
Commit Graph

201 Commits

Author SHA1 Message Date
Dan Walsh
ddc8dd68f0 Allow user to specify alternative docker executables.
This will allow us to support docker-latest
2016-04-13 08:53:19 -04:00
Brent Baude
d9347d048b Atomic/scan.py: Custom docker args
Added the ability to define custom docker args in the plugin
configuration files for things like bind mounting dirs from
the host to the scanner image.

When parsing the atomic scan json files, we can now handle
'Vulnerabilities' or 'Results' for keys.

Added a --debug switch to the base atomic command to allow for
more specifics when an unwanted exception is raised.

Fixed minor bug where if no image/container is provided, the
scanner would still execute.
2016-04-12 15:18:02 -05:00
Brent Baude
6ed4994b0d Implement generic scanning in Atomic
As more scanners besides openscap become available, atomic
can now begin to leverage them.  The new scan function has
been broken out into its on file (scan.py).

The scan command itself now defaults to openscap but can
also be switched to blackduck with --scanner.

Atomic now can use a configuration file which is stored
in /etc/atomic.conf.  The location of the atomic conf
file can be overriden with the environment variable
'ATOMIC_CONF'.  In the case of the scan function,
we need the scanner defined in the configuration file
as well as the fully qualified image name and the
scan arguments.  Optionally, you can provide additional
custom docker arguments for the scanner as well
2016-04-07 09:33:00 -05:00
Brent Baude
48767a4f4d Atomic/top.py Make sure dockerd is running
Using self.ping(), we now check to make sure the docker
daemon is running before executing any code to display
atomic top.

This fixes a followup bug reported in:

https://bugzilla.redhat.com/show_bug.cgi?id=1300187#c5
2016-04-07 08:08:39 -05:00
Daniel J Walsh
93cb8d9e01 Fix shell expansion on commands.
Prior to dropping shell=true, shell expansion on run/install/uninstall was

working, now we break in the case of a command like



LABEL INSTALL 'bash -c "echo foo foo foo"'



Adding shlex.split rather then standard split will break this command into

['bash', '-c', '"echo foo foo foo"']



Which will be executed correctly.
2016-04-05 10:54:41 -04:00
Colin Walters
1365590b9f host: Pass through unlock -> ostree admin unlock
It's nicer for branding the command.  The more correct thing would be
to add it to the rpm-ostree daemon and pass through there, but we have
more important problems to fix for the production code path.  This is
just for local development, so the slightly dirty way is just fine.
2016-04-04 11:25:03 -04:00
Brent Baude
d67849a602 Use fully-qualified image name in info() and verify()
We now use the fully qualified image name (if not provided)
when dealing with atomic info and verify.  This is because
skopeo requires a fq image name to do remote inspection. As
an upside, it also makes atomic a little more user friendly
as well.

tests/integration/test_info.sh

Temporarly disabled a test due to an issue with skopeo
2016-03-21 09:05:28 -05:00
Dan Walsh
1f9ec454c7 Set PWD environment if not currently set 2016-03-10 14:39:12 -05:00
Dan Walsh
39251596ea Fixes for running atomic on python3 2016-03-10 09:23:15 -05:00
Brent Baude
84e8a8fd74 Improve error handling with the docker-py client
In python-docker-py-1.6, the error handling improved
significantly.  When a docker object cannot be found,
say with client.inspect(), it now throws a specific
exception called NotFound instead of the old, generic
Docker error.  We have now updated some of our functions
to use the specific error because it was 'covering' other
docker client failures such as API compatibilies.

Also added a new custom Error class to handle a common
error message we used repeatidly.  The new class is
called 'DockerObjectNotFound' and will output a
consistent messages and takes the dockerobject as input.
This is most commonly used when we verify the users'
input for validity and is different that the docker
client NotFound error.
2016-03-08 08:54:18 -06:00
Brent Baude
7c98bb39ea Atomic/diff.py Add release to version, name, and epoch of RPM
When an RPM diff was performed between two docker objects, we
previously only store the name, version, and epoch of the RPM for
comparision.  It turns out versioning information is also done in
the release portion as well.

This addresses https://github.com/projectatomic/atomic/issues/315
2016-03-04 14:32:53 -06:00
Brent Baude
0c68129440 Atomic/top.py - Fix when specifying container names or ids
Atomic top was broken when you passed it valid container names
or ids.  This is now fixed plus added a simple check for validate
that the names or ids are correct.

This addresses https://github.com/projectatomic/atomic/issues/314
2016-03-04 14:18:14 -06:00
Brent Baude
be0b56c616 Unify error messages for no docker daemon (BZ #1300187)
In the case where the docker daemon is not running, each
Atomic subcommand was returning a different error message. This
PR unifies the errors messages for each subcommand.

This work was done for Bugzilla #1300187
2016-02-23 15:45:40 -06:00
Dan Walsh
a24621ecb3 Bump atomic to atomic-1.9 2016-02-22 14:51:41 -05:00
Brent Baude
3f2cec13b6 Add test for atomic verify
Added a test case to test for failure when an image has
multiple repotags and is asked to be verified by image
id.  This should result in a failure.

Also, turned verify debug off.
2016-02-17 14:38:26 -06:00
Brent Baude
853dd872f3 Fix verify where an image is tagged more than once
In the case where an image was tagged more than once, atomic
verify would sometimes resolve the wrong fully qualified name
due to an ordering issue in one of the supporting functions.
2016-02-17 13:46:16 -06:00
Daniel J Walsh
5abdba16fb Merge pull request #303 from baude/atomic_autoversion
Atomic/client.py: Universal method for docker.Client()
2016-02-16 15:40:08 -05:00
Brent Baude
570ee912bd Atomic/help.py: cmd_env no longer a property
When the cmd_env defition had its property decorator removed,
a single call to cmd_env in help.py was missed.
2016-02-16 11:11:13 -06:00
Brent Baude
b09a1bc4d0 Atomic/client.py: Universal method for docker.Client()
All uses of docker.Client() (docker-py) now should be using
the DockerClient definition in client.py.  Any changes to the
client instantiation or function can now be changed in a
singular location.

Also, the DockerClient function has a fallback from
docker.AutoVersionClient to docker.Client using a try and
except condition.  This fixes an issue raised in:

https://github.com/projectatomic/atomic/issues/302

where atomic cannot be built due to imports when dockerd is not
running.
2016-02-16 10:41:19 -06:00
Giuseppe Scrivano
d79ab6a970 Atomic/atomic.py: Fix pylint error
cmd_env is not a property, remove the decorator.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-02-08 14:44:43 +01:00
Daniel J Walsh
6f92d67bb9 Merge pull request #296 from rhatdan/master
We are not calling self.cmd_env just passing the function
2016-02-05 13:40:33 +01:00
Brent Baude
5cc1d0dd09 Removal of remote inspection from docker
We stopped carrying a patch in docker that allows for a RESTFUL
probe of remote registries.  This function is being replaced
by a new package called skopeo.

The remote_inspection def was removed from the Docker.Client
class extension in atomic.py and is replaced by a def called
util.skopeo which returns the same json-based results.
2016-02-02 13:00:59 -06:00
Dan Walsh
4d961c4417 We are not calling self.cmd_env just passing the function
This actually calls the function to setup the environment.
2016-02-01 04:29:20 +01:00
Daniel J Walsh
43bebd5647 Merge pull request #292 from TomasTomecek/use-autoversion-client
use docker.AutoVersionClient to avoid API version mismatch
2016-02-01 04:10:25 +01:00
Tomas Tomecek
4eec706716 use docker.AutoVersionClient to avoid API version mismatch
400 Client Error: Bad Request ("client is newer than server (client API version: 1.21, server API version: 1.20)")

AutoVersionClient is in docker-py since 1.1:
https://github.com/docker/docker-py/blob/master/docs/change_log.md#110

Logic around features available in docker engine since version X is very
well defined in docker-py: it won't allow you to use a feature if it's
not available in docker daemon, e.g.:
9b3b096709/docker/api/exec_api.py (L12)
2016-01-30 12:02:55 +01:00
Daniel J Walsh
c893521978 Merge pull request #288 from baude/atomic_harden_shell
atomic: harden shell invocations (1248038)
2016-01-29 14:43:57 -05:00
Brent Baude
d81e7e651e atomic: harden shell invocations (1248038)
This addresses one of the two issues raised by bugzilla
1248038 where atomic is using shell=True on its subprocess
calls which exposes a security concern.

Two new functions were added to accomplish this.  The
first is a util.chk_call which is similar to util.subp
but it uses the python function check call instead of
Popen.

The second function is atomic.sub_env_strings.  Previously,
there was env variable substitution occuring with cmd_env and
the subprocess call.  That was one upside of the shell=True
usage.  Now, prior to calling util.chk_call, we pass the
intended command to sub_env_strings and use cmd_env to
perform the variable substitution.

We will address part 2 of the security concerns, which
is the handling of LABELS as strings, in a different
PR.
2016-01-29 13:32:22 -06:00
Jonathan Lebon
b7b975b2c5 Atomic/run.py: rewrap security helper strings
I noticed at least one spacing issue on the latest el7 build in those
outputs. This patch reworks the layout of the strings so that it's
easier to read in the source code and to make sure that there are no
spacing issues.

Text is exactly the same, other than fixing spacing and changing "hosts
network" to "host's network".
2016-01-25 16:09:41 -05:00
Martin Preisler
13efca4b5b Use the async API from openscap-daemon to perform CVE scans if possible
The async API has several advantages, namely:
- it doesn't take over the dbus message queue of openscap-daemon,
  other users can still query it and interact with it
- it allows better scheduling in the daemon itself, daemon will
  limit the amount of concurrent work
- in the future it will be possible to cancel the work (CTRL+C),
  the change in atomic already does everything necessary, this
  only needs to be fixed in the daemon

In case the user has an older version of openscap-daemon we fallback to
the old synchronous API with huge timeout.
2016-01-20 14:50:40 +01:00
Brent Baude
c71664ef97 Atomic/run.py: Add security implications messages based on RUN label
Laymen users who are told to run a image may not understand
the docker run switches that have security implications.  We
now look for the following switches:

* --privileged
* --cap-add
* --security-opt label:disable
* --net=host
* --pid=host
* --ipc=host

and output an appropriate security message.

Also, moved def run() from Atomic/atomic.py to Atomic/run.py
to reduce the size and the number of definitions in
Atomic/atomic.py.
2016-01-18 09:29:37 -06:00
Daniel J Walsh
b0587e2b62 Merge pull request #277 from rhatdan/images
Make git_images always return a list.
2016-01-17 08:56:38 -05:00
Daniel J Walsh
0917a40cce Merge pull request #273 from baude/atomic_help
Atomic/help.py: Display man-like help for an image
2016-01-15 15:48:42 -05:00
Brent Baude
70427a5159 Atomic/help.py: Display man-like help for an image
Images or containers can now have an associated
man-like help page to help users understand more
about the image.  Typical information included
are things like a longer description, if the image
needs to be installed, security implications, steps
to upgrade, etc.

The default behavior is for atomic to display
a file called help.1 (in man format) located in
the / of the docker object.  This default
can be overriden with the HELP LABEL.  The
HELP LABEL needs to be a fully qualified
command to work correctly.
2016-01-15 10:02:58 -06:00
Shishir Mahajan
873487c7de atomic migrate import cleanup
Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
2016-01-14 16:48:54 -05:00
Dan Walsh
1376e50de2 Make git_images always return a list. 2016-01-14 15:09:32 -05:00
Shishir Mahajan
4a5f0c1280 Fix atomic migrate test
Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
2016-01-14 10:35:17 -05:00
Dan Walsh
ded5d6b2af Remove path from docker, so it can be used by alternate directories 2016-01-13 16:46:25 -05:00
Colin Walters
70612963da Merge pull request #275 from bexelbie/bexelbie_docker_env
Use DOCKER_* environment variables
2016-01-11 10:10:35 -05:00
Brian (bex) Exelbierd
319c2e4038 atomic images now handles the zero image case
Prior to this fix, get_col_lengths() returned an error
if repo_tags was empty.  Now it returns minimal data
2016-01-11 12:28:32 +01:00
Brian Exelbierd
28860517af Use DOCKER_* environment variables
Utilize the docker environment variables for non-local
daemons
2016-01-10 23:57:07 +00:00
Brent Baude
3be7c2a052 Atomic/util.py: Hush benign pylint error
With CentOS and Debian, 'makes' were failing due to a
maybe-no-member pylint error.  The error is a false
positive.  Added #pylint: disable=maybe-no-member to hush
it.
2016-01-07 13:21:46 -06:00
Dan Walsh
45dcd6f8fa --prune is not working with python3 due to encoding 2016-01-06 14:24:44 -05:00
Antonio Murdaca
465ab1fc8f Atomic: top: add optional uid,gid,user,group to ps_args
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2015-12-23 18:19:41 +01:00
Brent Baude
76a4113428 Add -e to docker top to correct TTY issues (BZ 1293063)
Depending on if a container has an allocated tty, you can get
different results from docker top unless you pass the -e
argument.  Adding the -e option will give correct results
regardless.

This is documented in https://bugzilla.redhat.com/show_bug.cgi?id=1293063.
2015-12-21 10:08:22 -06:00
Daniel J Walsh
c2faa99a4f Merge pull request #264 from baude/atomic_verify_fixes
Correct blank version names
2015-12-21 10:04:17 -05:00
Brent Baude
3331c19094 Correct blank version names
Due to a bug in atomic verify, sometimes the local and remote
versions ended up being blank.
2015-12-19 08:49:13 -06:00
Daniel J Walsh
3bb66c0a15 Merge pull request #258 from jandryuk/patch-1
Pass integer to dmsetup
2015-12-18 14:56:37 -05:00
Daniel J Walsh
b66c2344da Merge pull request #257 from baude/baude_tests
Add tests for Atomic diff and top
2015-12-18 14:54:09 -05:00
Dusty Mabe
4762405819 Re-enable execution of "stop" label from image.
In 374d344 "stop" was converted to only expect the argument provided
to be the name/id of a running container. This eliminated the usage
where a user wanted to execute the "STOP" label from a container image
rather than actually stopping a named container. This commit re-enables
the functionality to be able to run a stop label.
2015-12-18 14:19:48 -05:00
Dusty Mabe
ec724f7bca Allow additional args to be provided to "stop". 2015-12-18 12:07:46 -05:00