18 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
f456a58118
utils: Improve safe formatter by handling more cases
Fixes: #2462.

- When there are field retrievals and subscript based retrievals in the format
string, exceptions are raised. Handle these safely.

- This eliminates are error such as "Notification missing required key during
translation: 'str' object has no attribute 'php");print($CONFIG'". when the
notification message contains
"{include_once("/var/www/html/config/config.php");print($CONFIG["dbpassword"] ??
""); }"

Tests:

- Updated unit tests pass.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-10-21 12:47:04 -04:00
James Valleroy
a5820bc36d
diagnostics: Add method to translate checks
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-01-18 22:18:56 -08:00
Sunil Mohan Adapa
2dd00a8f08
*: Fix all typing hint related errors
- Try to mark class variables in component classes.

- Leave typing hints generic, such as 'list' and 'dict' where content is usually
not filled, too complex, or context is unimportant.

- backups: Handle failure for tarfile extraction so that methods are not called
on potentially None valued variables.

- backups: Prevent potentially passing a keyword argument twice.

- dynamicdns: Deal properly with outcome of urlparsing.

- ejabberd: Deal with failed regex match

- email: Fix a mypy compliant when iterating a filtered list.

- tor: Don't reuse variables for different typed values.

- tor: Don't reuse variables for different typed values.

- operation: Return None explicitly.

- operation: Ensure that keyword argument is not repeated.

Tests:

- Where only typing hints were modified and no syntax error came up, additional
testing was not done.

- `mypy --ignore-missing-imports .` run successfully.

- Generate developer documentation.

- Service runs without errors upon start up.

- backups: Listing and restoring specific apps from a backup works.

- backups: Mounting a remote backup repository works.

- NOT TESTED: dynamicdns: Migrating from old style configuration works.

- ejabberd: Verify that setting coturn configuration works.

- email: Test that showing configuration from postfix works.

- tor: Orport value is properly shown.

- transmission: Configuration values are properly set.

- users: Running unit tests as root works.

- operation: Operation status messages are show properly during app install.

- ./setup.py install runs

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2023-09-25 20:03:24 -04:00
Sunil Mohan Adapa
3c7bc4a192
*: pylint: Explicitly specify encoding when open a file
This is recommended by PEP-0597: https://peps.python.org/pep-0597/

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-07-04 19:45:57 -04:00
Joseph Nuthalapati
af53064660
utils: Fix ruamel.yaml deprecation warnings
Fixes #2143

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
[sunil: Convert the class property to instance property for added safety]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-10-29 14:34:53 -07:00
Fioddor Superconcentrado
337e8c28dd
config: Add user websites as choices for homepage config.
Closes: #1981
Closes also most of threads in !1952.

Signed-off-by: Fioddor Superconcentrado <fioddor@gmail.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-12-13 08:20:26 -05:00
Sunil Mohan Adapa
9368504da5
*.py: Use SPDX license identifier
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-02-19 14:38:55 +02:00
Alice Kile
eb83e00011
fix formatting issues
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-07 13:08:35 -05:00
Nikolas Nyby
d2e987ef3c
Fix a handful of typos in docs and comments
Found with [codespell](https://github.com/codespell-project/codespell/)

Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-07-24 12:39:11 -07:00
Sunil Mohan Adapa
717c3b39e9
utils: Convert tests to pytest style
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2019-05-12 17:16:52 +05:30
Sunil Mohan Adapa
96e7fd3e40
utils: Fix some flake8 warnings
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-02-18 21:51:24 -05:00
Sunil Mohan Adapa
d3bdaf0729
utils: Handle exceptions in context management for YAMLFile
When an exception is raised within the context, the YAML file should not
written.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-02-18 21:51:20 -05:00
Sunil Mohan Adapa
8f4811b350
Rename Plinth to FreedomBox in more module doc strings
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-16 20:10:31 -05:00
Sunil Mohan Adapa
dea4af17fb
Rename Plinth to FreedomBox in license headers
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-16 20:10:09 -05:00
Joseph Nuthalpati
6b8745fd17
captcha: fix failing test
Fixed a test that failed because of fixing a django deprecation warning.
request.user.is_authenticated() method is replaced by the property
`is_authenticated`

Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-10-17 22:08:27 -04:00
Joseph Nuthalpati
0a6e45f1cc
Remove print statement from tests
Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>
2017-08-28 16:01:24 +05:30
Joseph Nuthalpati
5ad180fcc9
Add Tahoe-LAFS module
- Created basic plinth app which starts an introducer and a storage
  node on the FreedomBox.
- Prompt user to set a domain name before creating Tahoe-LAFS nodes.
- Support adding and removing of introducers to the storage node.
- Serve Tahoe-LAFS from a different port.
- Start all nodes and introducers at system startup.
- Add utility class YAMLFile with test cases.
2017-06-10 09:38:57 -04:00
Sunil Mohan Adapa
1f5f1e0460
utils: Write tests for checking is user admin
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2017-04-30 08:37:03 +05:30