-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
[security] Adding docstrings and type hints #7952
[security] Adding docstrings and type hints #7952
Conversation
df0b27e
to
576947e
Compare
Codecov Report
@@ Coverage Diff @@
## master #7952 +/- ##
==========================================
+ Coverage 65.61% 65.62% +<.01%
==========================================
Files 469 469
Lines 22381 22388 +7
Branches 2432 2432
==========================================
+ Hits 14686 14692 +6
- Misses 7574 7575 +1
Partials 121 121
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #7952 +/- ##
==========================================
+ Coverage 65.61% 65.62% +<.01%
==========================================
Files 469 469
Lines 22381 22388 +7
Branches 2432 2432
==========================================
+ Hits 14686 14692 +6
- Misses 7574 7575 +1
Partials 121 121
Continue to review full report at Codecov.
|
576947e
to
d6a8259
Compare
def datasource_access_by_fullname(self, database, table_in_query, schema): | ||
table_schema, table_name = self.get_schema_and_table(table_in_query, schema) | ||
return self.datasource_access_by_name(database, table_name, schema=table_schema) | ||
def _datasource_access_by_fullname( |
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.
Note I find the naming of this method somewhat confusing and there's also a method called _datasource_access_by_name
, i.e, without the full
.
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.
yeah this is super confusing. I'm probably an outlier among those reading this, but I don't know what "fallback sql schema" means, would it be appropriate to clarify that here in the param docs? I realize it might be part of the superset codebase vernacular and maybe shouldn't be repeated everywhere it is used, if that's the case then cool. :-)
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.
@DiggidyDave I added more documentation regarding the "fallback SQL schema".
d6a8259
to
8cccd26
Compare
👍 agreed! if something is important enough that folks have invented 3 ways of doing it, it probably should have a first-class type :-) Thanks for doing all of this work |
3ab7175
to
5b728d4
Compare
5b728d4
to
e463d86
Compare
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.
Awesome work 👍 Apart from the small comment about I202
LGTM.
if TYPE_CHECKING: | ||
from superset.models.core import Database, BaseDatasource | ||
|
||
from superset.utils.core import DatasourceName # noqa: I202 |
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.
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.
@villebro I can create another PR which ignores I202
and removes all references.
`all_datasource_access` permission""".format( | ||
datasource.name | ||
) | ||
def get_datasource_access_error_msg(self, datasource: "BaseDatasource") -> str: |
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.
Why is this in quotes?
Edit: googled it, learned something new 👍
CATEGORY
Choose one
SUMMARY
This PR adds doc-strings and type hints to the security manager to help to provide more context and consistency. Note I've tried to ensure that the code remains unchanged however:
SupersetSecurityManager
(it's becoming almost intractable) I renamed private methods with a leading_
(underscore).A few notes/observations:
str
:[[cluster.]schema.]table
Tuple[str, str]
:(schema, table)
DatasourceName
I believe there would be merit in aligning on one mechanism for defining SQL tables throughout Superset to help mitigate bugs/inaccuracies (note we've addresses issues related to this in the past). This is especially vital as it relates to security and a hardened security model should be one of Superset's core tenets. A
dataclass
class may be a viable route.get_schema_perm
logic is correct as I believe that thedatabase
parameter can beUnion[Database, str]
. I'm not sure if that was intentionalTEST PLAN
CI.
ADDITIONAL INFORMATION
REVIEWERS
to: @DiggidyDave @etr2460 @michellethomas @mistercrunch @villebro