question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ngclient updater: API functions argument validation

See original GitHub issue

Description of issue or feature request: In the tuf/ngclient/updater.py module we are providing a couple API functions with arguments: Updater.__init__, get_one_valid_targetinfo, updated_targets and download_targets. It seems to me it’s a good idea to decide which arguments in those functions require validation and if there should be any what it should be.

Current behavior: No validation is done for:

  • repository_dir in Updater.__init__()
  • target_path in Updater.get_targetinfo()
  • maybe targetinfo in Updater.download_target()
  • maybe target_base_url in Updater.download_target()

Expected behavior: Decide if we want to add validation and if there is any what it should be:

  • repository_dir in Updater.__init__()
  • target_path in Updater.get_targetinfo()
  • targetinfo in Updater.download_target()
  • target_base_url in Updater.download_target()

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jkucommented, Nov 9, 2021

WRT validating TargetFile arguments, I guess the potential check would be “is this really a TargetFile instance?” but considering that A) we support static type checking (well almost anyway: #1633) and B) there is never any need to modify the targetfile in application code C) it will fail pretty gracefully anyway, I don’t think that check is needed…

We can validate that repository_dir does exist and throw an error otherwise

I think this currently ends up complaining that repository_dir/root.json does not exist – which seems like an accurate description of the problem: the updater isn’t interested in just the directory, it needs a directory with a root.json.

So potentially we don’t need to do anything here: I’m fine with that

0reactions
jkucommented, Nov 9, 2021

Yep, I think we agree here, let’s close

Read more comments on GitHub >

github_iconTop Results From Across the Web

Argument Validation Functions - MATLAB & Simulink
MATLAB defines functions for use in argument validation. These functions support common use patterns for validation and provide descriptive error messages.
Read more >
Add argument validation to your GraphQL Nexus API. - GitHub
The validate method can be added to any field with args : const UserMutation = extendType({ type: 'Mutation', definition(t) { t. field('createUser', {...
Read more >
Application - Servoy 2020 Documentation
The arguments that are given to the function when called. Supported Clients. SmartClient,WebClient,NGClient. Sample.
Read more >
Extension API: Argument Validation - JerryScript
This enables complex validation like handling different JS function signatures, mapping multiple input arguments to a C struct, etc.
Read more >
python - Best way to check function arguments? - Stack Overflow
A History of API Violence. Python 3.5 provides no actual support for using PEP 484 types. wat? It's true: no type checking, no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found