summaryrefslogtreecommitdiff
path: root/test/libapt
Commit message (Collapse)AuthorAgeFilesLines
* Remove code tagged APT_PKG_590, add some missing includesJulian Andres Klode2020-02-181-84/+0
| | | | | | Remove all code scheduled to be removed after 5.90, and fix files to include files they previously got from hashes.h including more headers.
* patterns: test for empty terms, reject themJulian Andres Klode2020-02-031-0/+26
|
* Correctly stop parsing short form arguments on space, also on ?Julian Andres Klode2020-02-031-0/+2
| | | | | | | | | we have to stop parsing on space so that things like ~ramd64 | ~rall work correctly. aptitude does not stop parsing on ?, but we'll do as it gets very confusing otherwise if you write stuff like ~ramd64?name(foo), and it resolves to ?and(?architecture(amd64?name), (foo))...
* patterns: Implement parsing of (...) groupsJulian Andres Klode2020-02-031-0/+4
|
* Implement | as orJulian Andres Klode2020-02-031-0/+3
|
* patterns: Parse sequence of patterns as ?andJulian Andres Klode2020-02-031-0/+8
|
* patterns: Allow bare words only in argumentsJulian Andres Klode2020-02-031-7/+24
| | | | | | | | | | | | | | | | This changes the syntax from approximately expr = unary unary = '!'? primary primary = pattern | short-pattern | word | quoted-word pattern = '?' name [ '(' expr [',' expr]* ')' ] short-pattern = ~ name | ~name expr to: primary = pattern | short-pattern argument = word | quoted-word | expr pattern = '?' name [ '(' argument [',' argument]* ')' ] short-pattern = ~ name | ~name argument
* patterns: Implement unary !Julian Andres Klode2020-02-031-0/+1
|
* Implement short patterns (patterns starting with ~)Julian Andres Klode2020-02-031-0/+66
| | | | | | Also make pattern detector in cacheset and private's list accept such patterns. We probably should just try to parse and see if it is a (start of a) pattern.
* Deprecate the Summation classes and mark them for removalJulian Andres Klode2020-01-141-31/+35
|
* gtests: Fix netrc parser test regression from https-only changesJulian Andres Klode2020-01-071-24/+57
| | | | | | We missed that because the CI never ran GTests, because it did not find the GTest library and failed silently (until the previous commit).
* Add support for GTest 1.9, do not fail silently if its missingJulian Andres Klode2020-01-071-24/+31
| | | | | | Require passing -DWITH_TESTS=OFF to CMakeList to disable unit tests, rather than ignoring them if GTest cannot be found; which just happened on CI...
* Fix use of GTest to adjust for GTest 1.9Julian Andres Klode2019-09-191-1/+1
| | | | | | GTest 1.9 uses a variable defined in the parent directory, thus failing to configure. Configure the project in the parent directory instead.
* Add initial support for parsing patterns into parse treesJulian Andres Klode2019-08-151-0/+95
| | | | | | | | | | | | | | | | | Introduce a parser for patterns that generates a parse tree. The language understood by the parser is: pattern = '?'TERM | '?'TERM '(' pattern (',' pattern)* ','? ')' | WORD | QUOTED-WORD TERM = [0-9a-zA-Z-] WORD = [0-9a-ZA-Z-.*^$\[\]_\\] QUOTED_WORD = "..." # you know what I mean This language is context free, which is a massive simplification from aptitude's language, where ?foo(bar) could have two different meanings depending on whether ?foo takes an argument or not.
* Adjust code for missing includes/using std::stringJulian Andres Klode2019-06-121-0/+1
|
* Make APT::StringView publicJulian Andres Klode2019-06-111-3/+0
|
* CMake: Enforce "override" use on overriden methodsJulian Andres Klode2019-05-061-0/+2
| | | | | This ensures that we do not accidentally stop overriding a method because it's signature changed in an API break.
* Merge libapt-inst into libapt-pkgJulian Andres Klode2019-05-061-1/+1
|
* Merge branch 'pu/refuseunsignedlines' into 'master'Julian Andres Klode2019-02-011-26/+138
|\ | | | | | | | | Fail if InRelease or Release.gpg contain unsigned lines See merge request apt-team/apt!45
| * Refuse files with lines unexpectedly starting with a dashDavid Kalnischkies2019-01-281-1/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We support dash-encoding even if we don't really work with files who would need it as implementations are free to encode every line, but otherwise a line starting with a dash must either be a header we parse explicitly or the file is refused. This is against the RFC which says clients should warn on such files, but given that we aren't expecting any files with dash-started lines to begin with this looks a lot like a we should not continue to touch the file as it smells like an attempt to confuse different parsers by "hiding" headers in-between others. The other slightly more reasonable explanation would be an armor header key starting with a dash, but no existing key does that and it seems unlikely that this could ever happen. Also, it is recommended that clients warn about unknown keys, so new appearance is limited.
| * Fail instead of warn for unsigned lines in InReleaseDavid Kalnischkies2019-01-231-25/+14
| | | | | | | | | | | | | | | | | | | | | | | | The warnings were introduced 2 years ago without any reports from the wild about them actually appearing for anyone, so now seems to be an as good time as any to switch them to errors. This allows rewritting the code by failing earlier instead of trying to keep going which makes the diff a bit hard to follow but should help simplifying reasoning about it. References: 6376dfb8dfb99b9d182c2fb13aa34b2ac89805e3
* | Step over empty sections in TagFiles with commentsDavid Kalnischkies2019-02-011-0/+2
|/ | | | | | | | Implementing a parser with recursion isn't the best idea, but in practice we should get away with it for the time being to avoid needless codechurn. Closes: #920317 #921037
* CMake: Use ${PROJECT_NAME} instead of hardcoding aptDavid Kalnischkies2018-08-141-6/+7
| | | | | | | Completely pointless as it makes no difference for apt, but copying the file to other projects becomes a lot easier. Gbp-Dch: Ignore
* Fix various typos reported by spellcheckersDavid Kalnischkies2018-05-052-4/+5
| | | | | Reported-By: codespell & spellintian Gbp-Dch: Ignore
* Prevent GTest from flooding us with compiler warningsDavid Kalnischkies2018-05-0420-187/+193
| | | | | | | | | | | | | | GTest has a bunch of undefined macros which causes the compiler to spit out warnings for each one on each test file. There isn't much we can do, so we just disable the warning for the testcases. Other warnings like sign-promo and sign-compare we can avoid by being more explicit about our expected integer constants being unsigned. As we are just changing testcases, there is no user visible change which would deserve to be noted in the changelog. Gbp-Dch: Ignore Reported-By: gcc-8
* Fix build with new gtestJulian Andres Klode2018-05-041-1/+1
| | | | | | Still allow the older one to be used. Closes: #897149
* apt-pkg: Add support for zstdJulian Andres Klode2018-03-121-2/+2
| | | | | | | zstd is a compression algorithm developed by facebook. At level 19, it is about 6% worse in size than xz -6, but decompression is multiple times faster, saving about 40% install time, especially with eatmydata on cloud instances.
* Support cleartext signed InRelease files with CRLF line endingsDavid Kalnischkies2018-01-021-10/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 89c4c588b275 ("fix from David Kalnischkies for the InRelease gpg verification code (LP: #784473)") amended verification of cleartext signatures by a check whether the file to be verified actually starts with "-----BEGIN PGP SIGNATURE-----\n". However cleartext signed InRelease files have been found in the wild which use \r\n as line ending for this armor header line, presumably generated by a Windows PGP client. Such files are incorrectly deemed unsigned and result in the following (misleading) error: Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?) RFC 4880 specifies in 6.2 Forming ASCII Armor: That is to say, there is always a line ending preceding the starting five dashes, and following the ending five dashes. The header lines, therefore, MUST start at the beginning of a line, and MUST NOT have text other than whitespace following them on the same line. RFC 4880 does not seem to specify whether LF or CRLF is used as line ending for armor headers, but CR is generally considered whitespace (e.g. "man perlrecharclass"), hence using CRLF is legal even under the assumption that LF must be used. SplitClearSignedFile() is stripping whitespace (including CR) on lineend already before matching the string, so StartsWithGPGClearTextSignature() is adapted to use the same ignoring. As the earlier method is responsible for what apt will end up actually parsing nowadays as signed/unsigned this change has no implications for security. Thanks: Lukas Wunner for detailed report & initial patch! References: 89c4c588b275d098af33f36eeddea6fd75068342 Closes: 884922
* support multiline values in LookupTagDavid Kalnischkies2017-12-131-0/+42
| | | | | | | | | | LookupTag is a little helper to deal with rfc822-style strings we use in apt e.g. to pass acquire messages around for cases in which our usual rfc822 parser is too heavy. All the fields it had to deal with so far were single line, but if they aren't it should really produce the right output and not just return the first line. Error messages are a prime candidate for becoming multiline as at the moment they are stripped of potential newlines due to the previous insufficiency of LookupTag.
* avoid some useless casts reported by -Wuseless-castDavid Kalnischkies2017-12-132-3/+3
| | | | | | | | | The casts are useless, but the reports show some where we can actually improve the code by replacing them with better alternatives like converting whatever int type into a string instead of casting to a specific one which might in the future be too small. Reported-By: gcc -Wuseless-cast
* Work around float rounding change in gcc 7 on i386Julian Andres Klode2017-08-121-1/+1
| | | | This caused a build failure in the test suite.
* reimplement and document auth.confDavid Kalnischkies2017-07-261-0/+223
| | | | | | | | | | | | | | | | | | We have support for an netrc-like auth.conf file since 0.7.25 (closing 518473), but it was never documented in apt that it even exists and netrc seems to have fallen out of usage as a manpage for it no longer exists making the feature even more arcane. On top of that the code was a bit of a mess (as it is written in c-style) and as a result the matching of machine tokens to URIs also a bit strange by checking for less specific matches (= without path) first. We now do a single pass over the stanzas. In practice early adopters of the undocumented implementation will not really notice the differences and the 'new' behaviour is simpler to document and more usual for an apt user. Closes: #811181
* use FileFd to parse all apt configuration filesDavid Kalnischkies2017-07-262-2/+52
| | | | | | Using different ways of opening files means we have different behaviour and error messages for them, so by the same for all we can have more uniformity for users and apt developers alike.
* Reformat and sort all includes with clang-formatJulian Andres Klode2017-07-1221-35/+35
| | | | | | | | | | | | | This makes it easier to see which headers includes what. The changes were done by running git grep -l '#\s*include' \ | grep -E '.(cc|h)$' \ | xargs sed -i -E 's/(^\s*)#(\s*)include/\1#\2 include/' To modify all include lines by adding a space, and then running ./git-clang-format.sh.
* Refactor to avoid loop/dangling gcc warningsDavid Kalnischkies2017-06-262-0/+6
| | | | Gbp-Dch: Ignore
* Fix and avoid quoting in CommandLine::AsStringDavid Kalnischkies2017-03-191-1/+9
| | | | | | | | | | | | | | | | In the intended usecase where this serves as a hack there is no problem with double/single quotes being present as we write it to a log file only, but nowadays our calling of apt-key produces a temporary config file containing this "setting" as well and suddently quoting is important as the config file syntax is allergic to it. So the fix is to ignore all quoting whatsoever in the input and just quote (with singles) the option values with spaces. That gives us 99% of the time the correct result and the 1% where the quote is an integral element of the option … doesn't exist – or has bigger problems than a log file not containing the quote. Same goes for newlines in values. LP: #1672710
* CMake: Document that the globs are expanded during CMakeJulian Andres Klode2017-01-171-0/+3
| | | | | | | This will avoid people from thinking that they have to do nothing when they change the set of files. Gbp-Dch: ignore
* Read dpkg tables to handle architecture wildcardsJulian Andres Klode2017-01-171-22/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our implementation of wildcards was rudimentary. It worked for some common ones, but it was also broken: For example, armel matched any-armel, but should match any-arm. With this commit, we load the correct tables from dpkg. Supported are both triplets and quadruplet tables (the latter introduced in dpkg 1.18.11). There are some odd things we have to deal with in the cache filter for historical and API reasons: * The character "*" must be accepted as an alternative to any - in fact it may appear anywhere in the wildcard as we also allow fnmatch() style wildcard matching on the commandline. * The code might get passed an arch with a minus at the end, for example the cmdline "install apt:any-arm-" will first try to check if any-arm- is a valid architecture. We deal with this by rejecting any wildcard ending in a minus. * Triplets are actually implemented by extending them to faux quadruplets - by prepending a "base" component for the architecture tuple, and "any" if there is a wildcard component. Once we have constructed a wildcard, it is transformed into an fnmatch() expression for historical reasons. In the future, we should really get a tuple class and implement matching in a better, more explicit way. This does for now though - it passes all the test cases and accepts all things it should accept. Closes: #748936 Thanks: James Clarke <jrtc27@jrtc27.com> for the initial patch
* Run parsedepends_test for two different native archsJulian Andres Klode2017-01-021-40/+43
| | | | | | | Run the test for kfreebsd-i386 and amd64 and pass "amd64" as an additional argument to the function. This tests that the argument is used and thus ParseDepends returns the amd64 results even on a different architecture like i386.
* warn if clearsigned file has ignored content partsDavid Kalnischkies2016-12-313-0/+356
| | | | | | | | | | | | | Clearsigned files like InRelease, .dsc, .changes and co can potentially include unsigned or additional messages blocks ignored by gpg in verification, but a potential source of trouble in our own parsing attempts – and an unneeded risk as the usecases for the clearsigned files we deal with do not reasonably include unsigned parts (like emails or some such). This commit changes the silent ignoring to warnings for now to get an impression on how widespread unintended unsigned parts are, but eventually we want to turn these into hard errors.
* optional write aptwebserver log to client specific filesDavid Kalnischkies2016-11-251-0/+39
| | | | | | | | | | | | The test test-handle-redirect-as-used-mirror-change serves multiple clients at the same time, so the order of the output is undefined and once in a while the two clients will intermix their lines causing the grep we perform on it later to fail making our tests fail. Solved by introducing client-specific logfiles which we all grep and sort the result to have the results more stable. Git-Dch: Ignore
* follow the googletest merge in build-dependsDavid Kalnischkies2016-11-251-2/+4
|
* Do not read stderr from proxy autodetection scriptsJulian Andres Klode2016-10-042-0/+35
| | | | | | | | | | | | | This fixes a regression introduced in commit 8f858d560e3b7b475c623c4e242d1edce246025a don't leak FD in AutoProxyDetect command return parsing which accidentally made the proxy autodetection code also read the scripts output on stderr, not only on stdout when it switched the code from popen() to Popen(). Reported-By: Tim Small <tim@seoss.co.uk>
* CMake: test/libapt: Use a prebuilt GTest library if availableJulian Andres Klode2016-09-021-15/+26
| | | | | | | If a non-existing source directory is specified, try finding the system gtest library. Debian derived distributions are a bit strange because they only ship the source code and not the library...
* tests: silence -Wmissing-declarationsDavid Kalnischkies2016-09-013-7/+3
| | | | | Gbp-Dch: Ignore Reported-By: gcc -Wmissing-declarations
* tests: don't do boundless string compares with data()David Kalnischkies2016-08-121-9/+11
| | | | Git-Dch: Ignore
* ensure a good clock() value for usage and testsDavid Kalnischkies2016-08-121-1/+9
| | | | | | | | | | | We use clock() as a very cheap way of getting a "random" value, but the manpage warns that this could return -1, so we should be dealing with this. Additionally, e.g. on hurd-i386 the value increases only slowly – to slow for our fast running tests for randomness hence producing the same range in both samples, so we introduce a simple busy-wait loop (as clock is counting processor time used by the program) in the test which delays the second sample just enough making our randomness a bit more predictable.
* don't perform int<float in progress bar drawingDavid Kalnischkies2016-08-121-1/+6
| | | | | | | | Comparing floating numbers is always fun and in this instance a 9 < 9.0 is "somehow" true on hurd-i386 letting the tests fail by reporting that too much progress achieved. A bit mysterious, but with some rework we can use code which avoids dealing with the floats in this way entirely and make our testcases happy.
* allow user@host (aka: no password) in URI parsingDavid Kalnischkies2016-08-101-0/+12
| | | | If the URI had no password the username was ignored
* Get rid of the old buildsystemJulian Andres Klode2016-08-101-84/+0
| | | | Bye, bye, old friend.