-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate and clean sysobjectid in NetboxTypeForm #2584
Validate and clean sysobjectid in NetboxTypeForm #2584
Conversation
Codecov Report
@@ Coverage Diff @@
## 5.6.x #2584 +/- ##
==========================================
- Coverage 53.89% 53.86% -0.04%
==========================================
Files 558 558
Lines 40612 40594 -18
==========================================
- Hits 21887 21864 -23
- Misses 18725 18730 +5
... and 10 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you've actually latched on to the third of three complementary solutions suggested in #2566 - but this doesn't seem to do what is actually suggested: Prevent someone from entering a sysObjectID value with a leading .
(in fact, you've added to test to ensure a leading .
is explicitly allowed).
An alternate twist to this might be to just strip the leading .
before storing the value.
On another note, you might want to have a look into the class nav.oids.OID
for this. This could be used to validate an OID - but this class will allow leading .
-s (since these are normally allowed, it's just type.sysobjectid
that's weird).
Yes, that is exactly what I've done: instead of not allowing the user to enter a sysObjectID value with a leading And I had a look at the |
Indeed, I managed to misread that part :)
I beg to differ: >>> from nav.oids import OID
>>> OID('foobar')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/mvold/d/nav/python/nav/oids.py", line 53, in __new__
return tuple.__new__(cls, oid)
ValueError: invalid literal for int() with base 10: 'foobar'
>>> OID('1,2,3,4')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/mvold/d/nav/python/nav/oids.py", line 53, in __new__
return tuple.__new__(cls, oid)
ValueError: invalid literal for int() with base 10: '1,2,3,4'
>>> OID('1.2.3.4')
OID('.1.2.3.4')
>>> OID('.1.2.3.4')
OID('.1.2.3.4')
>>> What good would the OID class be if it didn't validate its input? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - just nitpicking the changelog again ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good 'nough
fcf827f
to
e82ff41
Compare
Kudos, SonarCloud Quality Gate passed! |
Closes #2566.