20 Commits

Author SHA1 Message Date
linsui
cd1630d2f5 Lazyload environment variables in config.yml 2025-06-11 13:02:09 +00:00
linsui
e957583337 common: add calculate_gradle_flavor_combination 2025-05-22 12:24:32 +02:00
Hans-Christoph Steiner
20b36f1970 SOURCE_DATE_EPOCH from app's git otherwise fdroiddata metadata file
https://reproducible-builds.org/docs/source-date-epoch
2025-05-19 16:31:40 +02:00
Hans-Christoph Steiner
4e7bda736c update: never execute VCS e.g. git
Package repos come from untrusted sources, in terms of the buildserver. They
should be handled in VMs and containers as much as possible to avoid
vulnerabilities.  As far as I could tell, `fdroid update` only has a single
place where it executes any VCS system: if there is .fdroid.yml present in
a package repo, then it will fetch the commit ID using git.

For better security properties, this implements a simple function to just
read the files to get that commit ID.  The function that executes git to do
the same thing is relabeled "unsafe".  That is used for status JSON
everywhere, but that runs on fdroiddata.git and fdroidserver.git, which are
trusted repos.

The unsafe version is also used in places where git.Repo() is needed for
other things.
2025-05-12 18:30:03 +02:00
Hans-Christoph Steiner
9a8d80ee6b purge dead code: apk_signer_fingerprint_short 2025-03-31 11:09:07 +02:00
Hans-Christoph Steiner
0b3fe26524
skip tests that won't run on a given CPU architecture 2025-03-19 15:47:06 +01:00
Hans-Christoph Steiner
9d147c6b6b test_common: remove self.tmpdir and use standard self.testdir pat 2025-03-12 13:37:17 +01:00
Hans-Christoph Steiner
858068c64b only show "unsafe perms on config.yml" when secrets are present
This should make for fewer false positives.
2025-03-12 13:37:17 +01:00
Hans-Christoph Steiner
36007d50e5 AbstractBaseTest class for sharing setUp and tearDown in tests 2025-03-12 13:37:17 +01:00
Hans-Christoph Steiner
8cf1297e2c clarify config data types and structures 2025-03-12 13:37:17 +01:00
Hans-Christoph Steiner
081e02c109 expand {env: foo} in any place a string can be
`keypass: {env: keypass}` has been in use in production repos for
years.  That is not anything new. It makes it possible to maintain
_config.yml_ publicly even when it needs secrets.  This change makes
sure it is possible to use {env: foo} syntax anywhere where a string
value is valid. The "list of dicts" values can be str, list of str or
list of dicts with str.

Before the {env: keypass} syntax, the actual password was just inline
in the config file.  Before this commit, it was only possible to use
{env: key} syntax in simple, string-only configs, e.g. from
examples/config.yml:
2025-03-12 13:37:17 +01:00
Hans-Christoph Steiner
3ab2baf542 _yaml.config_dump() for writing out config
This outputs YAML in a string that is suitable for use in regexps
and string replacements, as well as complete files.  It is therefore
explicitly set up to avoid writing out headers and footers.
2025-03-10 08:49:18 +01:00
Hans-Christoph Steiner
2f47938dbf standardize config on ruamel.yaml with a YAML 1.2 config
This is a key piece of the ongoing `PUBLISH` _config.yml_ migration. There was uneven implementation of which YAML parser to use, and that could lead to bugs where one parser might read a value one way, and a different parser will read the value a different way. I wanted to be sure that YAML 1.2 would always work.

This makes all code that handles config files use the same `ruamel.yaml` parsers.  This only touches other usages of YAML parsers when there is overlap.  This does not port all of _fdroidserver_ to `ruamel.yaml` and YAML 1.2.  The metadata files should already be YAML 1.2 anyway.

# Conflicts:
#	fdroidserver/lint.py
2025-03-10 08:48:58 +01:00
Hans-Christoph Steiner
3cc6c09ffc use common var for 'config.yml', standarize on UTF-8
This makes it easy to track all the places that use config.yml, and
hopefully makes things feel cleaner.  This also standardizes all places
where config.yml is written out to use UTF-8 as the file encoding.

This also includes a lot of black code format fixes.
2025-03-05 12:20:32 +01:00
Hans-Christoph Steiner
642499ec94
purge config.py handling, it is no longer supported 2025-02-26 17:27:58 +01:00
Hans-Christoph Steiner
66d220bd9f tests: rename testcommon module to shared_test_code
This name always confuses me, since there is also test_common.py. And this
module is not actually a test suite, even though it starts with "test".
This also makes for better tab completion, e.g.

python3 -m unittest tests/te[Tab] -> tests/test_
2025-01-27 10:11:19 +00:00
Hans-Christoph Steiner
2ac925a249 ban apksigner v33, it has bugs verifying APKs with v3/v3.1 sigs 2025-01-21 15:00:23 +00:00
Hans-Christoph Steiner
20caa6fa1c match the full file name when looking for the v1 signature block
ZipFile.namelist() produces a string per file.  The filename could contain
newline chars, including at the beginning and end.  ^$ in regex matches
around newline chars.  \A\Z matches the beginning/end of the full string.

This is exactly the same as obfusk's r'\AMETA-INF/(?s:.)*\.(DSA|EC|RSA)\Z'
but in a readable format that is also easily searchable, and standard for
this code base.

https://github.com/obfusk/fdroid-fakesigner-poc/blob/master/fdroidserver-regex.patch

#1251
2025-01-15 14:45:35 +01:00
Hans-Christoph Steiner
5fde2f4d03
replace deprecated pkg_resources.get_distribution() from setuptools
This should fix the CI error for macOS and reduce technical debt.
https://gitlab.com/fdroid/fdroidserver/-/jobs/8542884186
2024-12-06 12:26:37 +01:00
SilentGhost
7ff32bc4b0 Refactor TestCase files into python modules
Convert all TestCase files into standard python modules to be run and
discovered by unittest.
2024-11-20 10:37:52 +01:00