-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Add sunpy Longitude180 to allowed mixin classes #6619
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
Conversation
This enables ecsv roundtripping for SunPy coordinates.
|
Hi there @Cadair 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labelled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃. I noticed the following issues with this pull request:
Would it be possible to fix these? Thanks! If there are any issues with this message, please report them here |
| 'astropy.coordinates.sky_coordinate.SkyCoord', | ||
| 'astropy.table.table.NdarrayMixin') | ||
| 'astropy.table.table.NdarrayMixin', | ||
| 'sunpy.coordinates.representation.Longitude180') |
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.
This seems confusing to me given that SunPy is not listed as optional dependency of Astropy. I feel like this should be within SunPy, not in core.
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 does seem like astropy should have a public registry for these that Sunpy could add to
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.
I don't disagree, any chance we could get this into a 2.0.x bug fix and I will add a registry for 3.0? It stops us round tripping coords to disk, which is really annoying.
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.
Putting into 2.0.x will require a stretch of what could be called a bug fix. I guess I would label this a highly desired backport and then have a policy discussion on if / when they are allowed.
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.
As is, I agree, but allowing subclasses serves the purposes and could be more easily argued to be a bug fix. It does mean, independently, that sunpy would only work with astropy >=2.0.3. But since it is a LTS, that may still be very useful.
|
@taldcroft - what do you think? The fact this PR is needed suggests that the current setup for |
|
The other option is that I can just monkey patch this in SunPy. I.e. change the hidden list from SunPy, so if you |
|
A possible alternative solution is to allow subclasses of anything in the current registry. I think part of having this was for security - one doesn't want to necessarily initialize random classes - but I'm having a bit of a hard time understanding how that would work: someone can receive a file with a malicious class in it, but for opening that file to be problematic, they would also need to convince the receiver to install a package that contains that class's definition. By that point, it would seem one is surely lost anyway. p.s. Yes, monkeypatching would solve this too, but that to me is mostly an argument for doing this right, as that means that now, effectively, this list is becoming part of the astropy API, since we would break sunpy if we moved it... |
|
@mhvk If someone can install a malicious class then the attack vector is not going to be opening the file, it's just going to be at install time. Allowing subclasses would also fox this. |
|
Sorry missed this issue earlier. Certainly in the initial implementation security was the concern and so having a small whitelist of classes all within Astropy was the idea. We need to think about this carefully, but at first glance I agree that it isn't obvious how one could construct an attack that way. Except of course the obvious that relies on ignorance, namely provide an ECSV data file that people want to read and put a comment that it uses blahblah package to subclass Angle and you need to install blahblah to read it. Then 95% of people will just do that without reading the code. Will ponder. |
|
I guess YAML has already "solved" this problem by having a |
|
Nevertheless putting in place a registry of ECSV-compatible classes via the |
|
It would also be nice to have a fallback mechanism where if a mixin class is unknown (because, say, I haven't got |
|
I would like to see a fix to this reasonably quickly. Being able to use ecsv round tripping is rather useful. another option is I PR the longitude wrap 180 class with this ;) |
I think this is a good idea independently of how to allow mixin classes - in fact, we could directly use this in |
|
I will open a PR with the Does anyone who has commented here see a way of getting a fix for this into the 2.0.z series? |
This enables ecsv roundtripping for SunPy coordinates.
This patches the following "bug":