WIP: Fix #105404: The USD Input operator does not validate the file received as input. #105659

Draft
Piyush Aniruddha Udhao wants to merge 2 commits from Piyush-Aniruddha-Udhao/blender:validating-usd-input-file into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
First-time contributor

There is no check to implement if the USD input operator inputs the right files. This pull request aims to fix that by first, storing the actual length of the input file in a variable int i. We find that by incrementing i till filename[i] is not equal to \0.
We know that a valid filepath is the one which ends with '.usd'. We check that by running an if-check for the invalid case, and if it returns a true value and we enter the if block, we report the error and return OPERATOR_CANCELLED.

Fixes #105404.

Alternate Solutions: The function RNA_string_get() calls RNA_property_string_get(), where an assertion on char *value could be implemented.

There is no check to implement if the USD input operator inputs the right files. This pull request aims to fix that by first, storing the actual length of the input file in a variable `int i`. We find that by incrementing `i` till `filename[i]` is not equal to `\0`. We know that a valid filepath is the one which ends with '.usd'. We check that by running an if-check for the invalid case, and if it returns a true value and we enter the if block, we report the error and return `OPERATOR_CANCELLED`. Fixes #105404. Alternate Solutions: The function `RNA_string_get()` calls `RNA_property_string_get()`, where an assertion on `char *value` could be implemented.
Piyush Aniruddha Udhao added 2 commits 2023-03-11 13:59:14 +01:00

The original report was about a directory instead of file being specified, which this does not cover.

Further USD has multiple possible file extensions like .usda and .usdz so this test is not correct. I don't think checking for file extensions is required at all really, we generally enforce those in file browser filtering but do not strictly forbid using a different extension.

The original report was about a directory instead of file being specified, which this does not cover. Further USD has multiple possible file extensions like .usda and .usdz so this test is not correct. I don't think checking for file extensions is required at all really, we generally enforce those in file browser filtering but do not strictly forbid using a different extension.
Author
First-time contributor

we generally enforce those in file browser filtering but do not strictly forbid using a different extension.

I too went into blender and tried to import the wrong file, but it did not allow me to. So this bug confused me. But then I thought, it's marked as a good first issue, why not submit a PR?

> we generally enforce those in file browser filtering but do not strictly forbid using a different extension. I too went into blender and tried to import the wrong file, but it did not allow me to. So this bug confused me. But then I thought, it's marked as a good first issue, why not submit a PR?
This pull request has changes conflicting with the target branch.
  • source/blender/editors/io/io_usd.c

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u validating-usd-input-file:Piyush-Aniruddha-Udhao-validating-usd-input-file
git checkout Piyush-Aniruddha-Udhao-validating-usd-input-file
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#105659
No description provided.