Commit Graph
30 Commits
Author SHA1 Message Date
William Douglas 90bcff8bf9 Remove pypi integrity checks
pypi is deprecating the API and doesn't recommend its usage for
integrity checks so stop trying to make use of it in autospec.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-05-30 15:41:38 -07:00
William Douglas 74c0833cf4 Remove ruby, golang and cargo build patterns
These patterns are being removed as they are not used or are going to
be reworked.

This change also removes support for multi-versioned packages which
were considered for go and cargo purposes.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-03-17 12:14:20 -07:00
Patrick McCarty 43904ea6e4 pkg_integrity: verify sha256 instead of md5 for pypi packages
All sdist tarballs available on pypi appear to have both an md5sum and
sha256sum listed, so switch to verify the stronger hash (sha256)
instead.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2022-08-05 13:57:30 -07:00
Patrick McCarty 91329815ae Remove other Travis CI leftovers
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2020-04-24 20:12:02 -07:00
William Douglas 4f90794393 Move target directory to Config
Many different components require the target download path and it is
needed early. Previously code existed to attempt to autodetect its
location and so defining the path was enforced later in the build
process. This created problems with ordering functions based on this
requirement but since the target path is now certain to be defined at
startup (due to previous changes) we can better align the location and
initialization of the data to the Config class.

As part of this change also avoid requiring the temporary working
directory to be setup as part of the Build class. This is done as a
cleanup due to the only real user of this location being the Content
class.

This also drops the stand-alone pkg_integrety main function that was
initially used as a one off test to avoid needing to run autospec to
validate the integrity of a package. This feature was seldom used and
doesn't function well without handling configuration so it was
dropped.
2020-04-14 14:14:14 -07:00
William Douglas 54636b48dd Refactor the config into a class
The config module had a large amount of globals that were being
touched across many modules that would import. This made changes to
config very fragile as figuring out what would be modified in any
given call chain was difficult to diagnose.

It also made testing fragile as one would need to reset a given
module's config import to the best of their knowledge before rerunning
another test.

To get away from that (and to try and reduce the number of globally
modified variablies in autospec as a whole), refactor the config
module to provide its state as part config class. The long running
goal of changes like this is to better track what content can be
updated by a particular function (if a function would have access
to the config instance is now the hint rather than the config module
getting imported).
2020-03-24 18:05:27 -07:00
Patrick McCarty 4d9d88733f tests: add new tests for the multiple-sig handling
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2020-01-21 14:33:32 -08:00
Patrick McCarty d0fcb20e90 pkg_integrity: only track parsed packets
There are only two GPG packet types that autospec needs to know about
for now ("signature" and "user ID"), so update `parse_gpg_packets` to
only add those packets for tracking.

Also, update unit tests to account for packets that are now skipped,
thus reducing the size of the packets list.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2020-01-21 14:33:32 -08:00
Patrick McCarty d766329ead tests: update pkg_integrity tests for recent changes
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2020-01-21 14:33:32 -08:00
Patrick McCarty 239d7296d2 pkg_integrity: enable qt package sha256 verification
The new QtIoVerifier class is largely based on GnomeOrgVerifier.

Also add a unit test for the successful verification case.

(Most of qt package tarballs are large, so I picked the smallest one,
qtspeech, which is 98KB.)

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2019-06-26 01:10:32 -07:00
Patrick McCarty 3f04dd7e5e Implement unified download interface
The download code for licenses, tarballs, and signature files are
similar enough to warrant consolidation into a unified interface, so add
a new function do_curl() that satisfies the needs of all the callers.

Note that I made one change that noticeably changes the output,
hopefully to reduce confusion: The signature download loop no longer
prints error messages, since the end user should not need to care at all
unless a signature cannot be downloaded and verification is required. If
the latter case is true, autospec will still exit and print the fatal
error, so the issue should be straightforward to diagnose after seeing
that error.

A couple of bugs are fixed as a result of using the new function:

  - The FAILONERROR pycurl option is now set for tarball downloads. This
    prevents certain undesirable side-effects like downloading 404
    response pages.

  - Responses from FTP servers are now handled better, since a more
    common "success" code from FTP servers is 226, not 200.

And unit tests have been updated:

  - Added new tests for download.do_curl().

  - Replaced "mock" import with "unittest.mock" for pkg_integrity tests.

  - Revised license and pkg_integrity tests to reflect the new download
    paths.

  - Added missing mocks for the download paths in PyPIVerifier and
    GEMShaVerifier.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2018-12-09 23:08:10 -08:00
William Douglas e87d067cb0 Fixups for pkg_integrity (and its tests)
Due to the test->check file rename, breakages in testing for
pkg_integrity were found. This uncovered actual problematic leftovers
in the GPGVerifier from the move to a stand alone download_file
function for all signatures.

Tests then needed to be updated to avoid running downloads as part of
their validation but we should add tests mocking the pycurl calls and
testing the rest of download_file at some point.
2018-11-07 11:22:36 -08:00
Arzhan Kinzhalin c962e38997 Change the signature files handling.
Instead of probing the url with HEAD, download the first available
signature, if any, and pass it to validator.

The concept of "validation from url" is, thus, gone. Downloading the
signature file is no longer part of the validation.
2018-10-19 16:36:30 -07:00
William Douglas 44ae8483c7 Assume samba.org packages use .asc signatures
Set signature type for samba.org packages to .asc also prefer .asc to
.sig files for signature detection.
2018-02-22 11:59:14 -08:00
Arzhan Kinzhalin cd11c14a7d Remove the shared keyring.
Keys now must be stored in the individual packages. autospec will import them
there (as opposed to this central locations). Packages were updated with their
current pub keys where possible.
2018-02-16 08:29:31 -08:00
Gabi Beyer e13d3edb03 Remove network dependencies for pkg_integrity test
Create a mock function that copies files from the testfiles
directory to a tmp directory, when attempting to download
files from the network.

Create a mock function for head_request that returns 404 for
a few specified urls, and 200 for the rest.

The mock calls will allow the functionality of the pkg_integrity
program to be tested and not dependent on networking. Tests will
no longer need to be skipped in travis with the removal of
network dependency.

Removed a few tests that were not specific to pkg_integrity, but
instead were testing the importing and exporting abilities
of the gpg key server.

Added mock as a requirement to the requirements.txt file.

Signed-off-by: Gabi Beyer <gabib@live.com>
2017-11-01 16:58:58 -07:00
Matthew Johnson 673ba4fd4c Skip debian pkg_integrity tests in Travis
Debian is down again, and we've seen them go down in the past. We
shouldn't be running these tests in Travis.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-10-16 14:54:34 -07:00
Matthew Johnson a09ea7005e Skip two more trouble tests in Travis
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-26 15:38:23 -07:00
Matthew Johnson adaea4202a Skip problem tests on Travis CI only
These tests regularly fail in Travis for unknown reasons. Skip them
until the tests can be rewritten.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-26 15:30:45 -07:00
Matthew Johnson 9b7bba0683 Create options.conf in relative directory
Instead of creating in the current directory, which assumes autospec is
being run via a make target from the package directory, create
options.conf in the target directory. This insures the configuration
file will be placed correctly when autospec is run directly with a
different target directory provided.
2017-04-25 12:08:01 -07:00
Alex Jaramillo f9ff1e11b1 Adding shasum verification for domain gnome.org
Implemented support for hash verification of packages from
download.gnome.org. This commit includes tests for domain
based verification (pypi ang gnome)
2017-04-06 21:42:26 +00:00
Alex Jaramillo f61aecd6ae Cleaning after test
Public key import was not cleanning after running. With this
change the state of the keyring will be reverted to the
original state after the test runs.
2017-04-03 16:07:10 +00:00
William Douglas 94245bda88 Delete temporary test file after use 2017-02-21 22:08:44 +00:00
Alex Jaramillo 4faa9e77df Verifying MD5 hashes for pypi packages
With this change python packages in pypi will be
verified using the MD5 hash posted in pypi along
the package if all the other verifications are
not possible.
2017-02-17 21:46:44 +00:00
Alex Jaramillo 4e4530744c Pkg verification interactive mode special cases
This patch adds handling for two cases for interactive
mode. 1- when non pty, the interactive mode is disabled
, and 2- timeout input function, when user fails to type
an input in interactive mode the script will continue
after a timeout.
2017-02-14 19:43:34 +00:00
Alex Jaramillo aa4393b213 Adding flag to disable interactive mode
This flag will be used for package verification interactive
mode, currently package verification will attempt to import
a public key if a public key id is found. With the addition
of this flag is possible to disable the default interactive
mode and instead fail the verification if the public key is
not already in the keyring.
2017-02-14 18:14:51 +00:00
Alex Jaramillo ed1bda5a8a Adding logic to handle proxy if env var exists
In some environments it might be neccesary to pass
http_proxy env var if this is not set otherwise the
attempt of find a key will fail since gpg will not
be able to find a keyserver if behind proxy.
2017-01-25 22:06:40 +00:00
Alex Jaramillo 9937cd1b32 Adding option to interactively import keys
When autospec fails to find a key it just quits
even when a keyid exists. With these changes users
will have the option to import a key without
quiting autospec.
2017-01-20 21:04:53 +00:00
Matthew Johnson a2baa7089e Add package signature as Source99 file
Add the package signature URL as a Source99 file to include it with the
source rpm. This allows the signature to be more traceable and
accessible even without a network connection.
2017-01-12 15:43:30 -08:00
Matthew Johnson 5407d741be Import refactor of pkg_integrity tests
Since pkg_integrity now depends on config.py, it is necessary to change
how imports are done in the tests so mocking can be achieved. This also
required renaming the tests/pkg_integrity.py file to
tests/test_pkg_integrity.py to avoid a name collision. Before each test
the necessary config option is set correctly and the configuration file
rewrite is mocked away.
2017-01-07 08:38:28 -08:00