summaryrefslogtreecommitdiff
path: root/test/libapt
Commit message (Collapse)AuthorAgeFilesLines
* Drop APT::StringViewнаб2025-02-141-99/+0
|
* Drop usage of macro APT_OVERRIDE for simple overrideDavid Kalnischkies2025-01-053-9/+9
| | | | | | | | | We were rather inconsistent in using it and as our public headers contain deduction guides (a c++17 feature) it seems silly to try to hide a c++11 feature in a macro, so lets stop this charade and drop the macro and while we are changing all these lines lets apply [[nodiscard]] (another c++17 feature) and other suggestions from clang-tidy and formatting for a little more consistency.
* Ensure we can build with APT_PKG_ABI > 601Julian Andres Klode2025-01-051-1/+4
| | | | | There were some references to APT::StringView that don't make much sense anymore.
* fileutl: Use execvp() in Popen() instead of execv()Julian Andres Klode2024-11-281-1/+1
|
* strutl: Add Base64DecodeJulian Andres Klode2024-11-281-1/+20
| | | | | | | | Lifted from the dpkg mtree code that mjg59 submitted in https://lists.debian.org/debian-dpkg/2018/05/msg00005.html Which as dpkg is GPL-2.0+ also is GPL-2.0+
* Fix expired std::string usage in APT::StringView testcaseDavid Kalnischkies2024-11-221-1/+2
| | | | | | | | The anonymous std::string we were using here to create the view expires after the construction of the view and so the gcc warning | warning: ‘<anonymous>’ may be used uninitialized [-Wmaybe-uninitialized] is correct in that the memory we are pointing to is potentially overridden/reused already, if a bit roundabout in saying so.
* test/libapt/strutil_test.cc: APT::StringView -> std::string_viewнаб2024-11-121-2/+1
|
* gpgv: Add IsAssertedPubKeyAlgo() functionJulian Andres Klode2024-07-151-0/+56
| | | | This checks whether a public key algorithm is asserted.
* Deal better with spurious spaces in arch restrictionsDavid Kalnischkies2024-05-161-0/+52
| | | | | | | | Another instance of our parser written for sane clean input, but nowadays used also for user-provided input which can contain very many strange formatting and especially white spaces all over the place. Closes: #1071219
* build: test: Silence warnings in GTest codeJulian Andres Klode2024-04-2033-32/+43
| | | | | GTest has a lot of broken things with signed vs unsigned, and double integer promotions, let's silence them.
* test: configuration: color: reset _config after testsJulian Andres Klode2024-04-201-0/+2
| | | | | | This avoids us polluting the configuration for later tests, since the test order apparently is not deterministic. We probably should fix some common test case thingy instead.
* Add APT::Configuration::color helper to colorize thingsJulian Andres Klode2024-04-191-0/+30
|
* Allow no spaces for the last dependency in ParseDepends, tooDavid Kalnischkies2024-04-171-0/+33
| | | | | | | | | | | | | | | | | | | | All other entries in a dependency line get substantial leeway about the amount of spaces surrounding the entry itself and its individual parts, but the very last entry was required to have a version constraint be at least 4 chars long (excluding opening bracket and spaces following it), so if the version is short and a single-char relation used a space had to make up for it. This is a bit unfair in comparison to the other entries who do not have such unreasonable demands, so we reduce our demand to 3 chars or longer, which is satisfied by "=1)". If it is a good idea to hate spaces that much remains unanswered by this commit, but in practice most tools (re)writing the files we parse will include spaces, so its only in files (or on the satisfy command line) directly edited by users that we can encounter such a situation, which is a relatively new development given this line came unchanged from the introduction of this method in 1998. LP: #2061834
* apt: Use unicode install progress bar on UTF-8 localesJulian Andres Klode2024-04-131-0/+20
| | | | | This produces a much more appealing progress bar and it can even show parts of the progress being done.
* Modernize standard library includesJulian Andres Klode2024-02-2011-17/+17
| | | | | | This was automated with sed and git-clang-format, and then I had to fix up the top of policy.cc by hand as git-clang-format accidentally indented it by two spaces.
* Use different variable name in GTest source path detectionDavid Kalnischkies2023-11-181-5/+5
| | | | | | | | | | | | | | | | | | | | | | We used GTEST_ROOT, which becomes an issue with 3.27 as that variable would influence find_package behaviour by providing PREFIXES – introduced with potentially mixed-cased name in 3.12. CMake Warning (dev) at test/libapt/CMakeLists.txt:8 (find_package): Policy CMP0144 is not set: find_package uses upper-case <PACKAGENAME>_ROOT variables. Run "cmake --help-policy CMP0144" for policy details. Use the cmake_policy command to set the policy and suppress this warning. CMake variable GTEST_ROOT is set to: /usr/src/googletest/googletest For compatibility, find_package is ignoring the variable, but code in a .cmake module might still use it. As using this new feature isn't what we wanted at all, we just use a different variable name to avoid the warning and potential future problems if we would keep using this name.
* Include our config.h in all C++ files to avoid ODR violationsDavid Kalnischkies2022-05-073-1/+7
| | | | | | | Some of our headers use APT_COMPILING_APT trickery to avoid exposing too broadly details we don't want external clients to know and make use of. The flip-side is that this can lead to different compilation units seeing different definitions if they aren't all using the same config.
* Streamline access to barbarian architecture functionalityDavid Kalnischkies2021-09-041-0/+28
| | | | | | | | | | | | | | | | | | | | | | APT is not the place this information should be stored at, but it is a good place to experiment and see what will be (not) needed in the future for a proper implementation higher up the stack. This is why "BarbarianArchitectures" is chosen instead of a more neutral and/or sensible "VeryForeign" and isn't readily exported in the API to other clients for this PoC as a to be drawn up standard will likely require potentially incompatible changes. Having a then outdated and slightly different implementation block a "good" name would be bad. The functionality itself mostly exists (ignoring bugs) since the introduction of MultiArch as we always had the risk of encountering packages of architectures not known to dpkg (forced onto the system, potentially before MultiArch) we had to deal with somehow and other edge cases. All this commit really does is allowing what could previously only be achieved with editing sources.list and some conf options via a single config option: -o APT::BarbarianArchitectures=foo,bar
* json: Encode NULL strings as nullJulian Andres Klode2021-04-231-0/+8
| | | | This is the only nullable thing we have here.
* json: Actually pop statesJulian Andres Klode2021-04-231-0/+16
| | | | | | | | | | | The JSON encoder only looked at the top state, but did not pop it, so if we nested objects, we got stuck in whatever the last state we pushed aside was, so in our example, we wrongly get a comma inserted _after_ key "b": {"a":[{}], "b":,[{}] }
* json: Escape strings using \u escape sequences, add testJulian Andres Klode2021-04-231-0/+45
| | | | | | | | This allows us to correctly encode strings containing quotation marks, escape characters and control characters. The test case is a bit nasty because it embeds private-cachefile.cc for linkage reasons.
* Check for and discard expected warning from MaybeAddAuthJulian Andres Klode2021-03-311-0/+5
| | | | | | | | | MaybeAddAuth() here tells us that it refused to use the credentials for an http source; but that caused the test suite to fail at a later stage because we checked if there were any errors/warning. Strangely, this is only triggered with LTO enabled. Actually check that the warning is being set and then reject it.
* Avoid overstepping bounds in config file parsingDavid Kalnischkies2021-02-031-0/+8
| | | | | | | Our configuration files are not security relevant, but having a parser which avoids crashing on them even if they are seriously messed up is not a bad idea anyway. It is also a good opportunity to brush up the code a bit avoiding a few small string copies with our string_view.
* Forbid negative values in unsigned StrToNum explicitlyDavid Kalnischkies2021-02-031-0/+56
| | | | | | | strtoul(l) surprises us with parsing negative values which should not exist in the places we use to parse them, so we can just downright refuse them rather than trying to work with them by having them promoted to huge positive values.
* Don't parse \x and \0 past the end in DeEscapeStringDavid Kalnischkies2021-02-031-0/+6
| | | | | | This has no attack surface though as the loop is to end very soon anyhow and the method only used while reading CD-ROM mountpoints which seems like a very unlikely attack vector…
* Fix incorrect base64 encoding due to int promotionDavid Kalnischkies2021-02-031-0/+4
| | | | | | | For \xff and friends with the highest bit set and hence being a negative value on signed char systems the wrong encoding is produced as we run into undefined behaviour accessing negative array indexes. We can avoid this problem simply by using an unsigned data type.
* Add a simple test for APT::String::DisplayLengthDavid Kalnischkies2021-02-031-0/+17
| | | | | References: 2497198e9599a6a8d4d0ad08627bcfc7ea49c644 Gbp-Dch: Ignore
* patterns: Terminate short pattern by ~ and !Julian Andres Klode2020-12-071-0/+2
| | | | | | | | | | This allows patterns like ~nalpha~nbeta and ~nalpha!~nbeta to work like they do in APT. Also add a comment to remind readers that everything in START should be in short too. Cc: stable >= 2.0
* Allow prefix to be a complete filename for GetTempFileDavid Kalnischkies2020-05-1813-347/+179
| | | | | | | | | | | | | Our testcases had their own implementation of GetTempFile with the feature of a temporary file with a choosen suffix. Merging this into GetTempFile lets us drop this duplicate and hence test more our code rather than testing our helpers for test implementation. And then hashsums_test had another implementation… and extracttar wasn't even trying to use a real tempfile… one GetTempFile to rule them all! That also ensures that these tempfiles are created in a temporary directory rather than the current directory which is a nice touch and tries a little harder to clean up those tempfiles.
* Parse records including empty tag names correctlyDavid Kalnischkies2020-02-261-0/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No sensible file should include these, but even insensible files do not gain unfair advantages with it as this parser does not deal with security critical files before they haven't passed other checks like signatures or hashsums. The problem is that the parser accepts and parses empty tag names correctly, but does not store the data parsed which will effect later passes over the data resulting e.g. in the following tag containing the name and value of the previous (empty) tag, its own tagname and its own value or a crash due to an attempt to access invalid memory depending on who passes over the data and what is done with it. This commit fixes both, the incidient of the crash reported by Anatoly Trosinenko who reproduced it via apt-sortpkgs: | $ cat /tmp/Packages-null | 0: | PACKAGE:0 | | : | PACKAGE: | | PACKAGE:: | $ apt-sortpkgs /tmp/Packages-null and the deeper parsing issue shown by the included testcase. Reported-By: Anatoly Trosinenko <anatoly.trosinenko@gmail.com> References: 8710a36a01c0cb1648926792c2ad05185535558e
* 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.