Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #324 +/- ##
===========================================
- Coverage 95.06% 79.13% -15.94%
===========================================
Files 5 5
Lines 324 690 +366
===========================================
+ Hits 308 546 +238
- Misses 16 144 +128 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: teolemon <1689815+teolemon@users.noreply.github.com>
Co-authored-by: teolemon <1689815+teolemon@users.noreply.github.com>
Co-authored-by: teolemon <1689815+teolemon@users.noreply.github.com>
…r type hints Co-authored-by: teolemon <1689815+teolemon@users.noreply.github.com>
| assert prop is not None | ||
| assert prop.wikidata_property == "P5196" | ||
| assert prop.wikidata_url is not None | ||
| assert "wikidata.org" in prop.wikidata_url |
Check failure
Code scanning / CodeQL
Incomplete URL substring sanitization High test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
Use proper URL parsing and assert on the hostname rather than checking for a substring in the full URL string.
Best fix in this file:
- In
tests/test_properties.py, importurlparsefromurllib.parse. - In
test_property_wikidata_links, replace the substring assertion with:- parse the URL (
parsed = urlparse(prop.wikidata_url)) - assert hostname exists
- assert hostname is exactly
wikidata.orgor ends with.wikidata.org(to allow valid subdomains safely)
- parse the URL (
This keeps behavior aligned with the original intent (“URL belongs to Wikidata”) while removing the incomplete substring sanitization pattern flagged by CodeQL.
| @@ -1,5 +1,7 @@ | ||
| """Tests for property documentation system.""" | ||
|
|
||
| from urllib.parse import urlparse | ||
|
|
||
| from folksonomy import property_loader | ||
| from folksonomy.models import PropertyDocumentation, PropertyList | ||
|
|
||
| @@ -126,7 +128,9 @@ | ||
| assert prop is not None | ||
| assert prop.wikidata_property == "P5196" | ||
| assert prop.wikidata_url is not None | ||
| assert "wikidata.org" in prop.wikidata_url | ||
| parsed = urlparse(prop.wikidata_url) | ||
| assert parsed.hostname is not None | ||
| assert parsed.hostname == "wikidata.org" or parsed.hostname.endswith(".wikidata.org") | ||
|
|
||
|
|
||
| def test_property_input_widget_types(): |
|
|
||
| if not PROPERTIES_DIR.exists(): | ||
| logger.warning(f"Properties directory not found: {PROPERTIES_DIR}") | ||
| _property_cache = properties |
| logger.error(f"Unexpected error loading {yaml_file}: {e}") | ||
| continue | ||
|
|
||
| _property_cache = properties |
Implements a beginner-friendly property documentation system independent of the Open Food Facts wiki, enabling web components and mobile apps to dynamically generate appropriate input forms and display property information in knowledge panels.
Core Implementation
data/properties/with 10 example properties (scoville_scale, storage_capacity, organic, caffeine_content, etc.)GET /properties- List/search propertiesGET /properties/{key}- Full documentationGET /properties/{key}/knowledge-panel- Panel configurationPropertyDocumentation,PropertyList)Property Schema Features
Each YAML file supports:
Integration Example
Documentation
data/properties/README.md- YAML schema specificationdata/properties/INTEGRATION.md- Web component and mobile app integration guide with Flutter/React Native examplesPROPERTY_SYSTEM.md- Architecture and implementation detailsNo database migrations required. Properties are read-only YAML files that can be updated without code changes.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.