dotnet / efcore

EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations.
https://docs.microsoft.com/ef/
MIT License
13.5k stars 3.13k forks source link

Support for data masking in sql server provider #20592

Open clement911 opened 4 years ago

clement911 commented 4 years ago

It would be great if we could configure the data masking behavior of columns via migrations.

Docs: https://docs.microsoft.com/en-us/sql/relational-databases/security/dynamic-data-masking

Ideally, there would be a DataMaskingAttribute that we could annotate properties with and the migration would ALTER the column accordingly.

I was inspired by this project: https://github.com/nikitasavinov/EntityFrameworkCore.Extensions

nguyenlamlll commented 4 years ago

+1 for this feature. We need supports for data masking. #ProtectTheSensitiveData

MyEidos commented 2 years ago

+1 for this feature.

roji commented 2 years ago

For anyone looking for this, it seems possible to adding data masking to an existing table; this means that it's pretty trivial to activate this feature by integrating raw SQL in your migrations, right after EF Core's generated migration code which creates the table.

While this isn't a perfect solution, it's quite a usable workaround, and also means that likely wouldn't be prioritized as highly as other features where EF Core support is absolutely required.

nikitasavinov commented 2 years ago

I'm the author of the small library mentioned above (https://github.com/nikitasavinov/EntityFrameworkCore.Extensions), which adds dynamic data masking support to EF Core although in a slightly dirty way as it messes with EF Core internals.

If the core team agrees to add this functionality to the framework, I'm happy to propose a design and implement data masking in EF Core (and get rid of my library).

roji commented 2 years ago

@nikitasavinov we'd certainly welcome this as a contribution! However, be aware that it is now quite late for introducing new enhancements for EF Core 6.0, and the team is currently very busy locking down EF Core 6.0 improvements. So this work would ideally happen for EF Core 7.0, and we'd have time to react to your design/PR starting from 2-3 months from now.

But at that point a design proposal followed by a PR would be great!

cfauchere commented 2 years ago

Is anyone working on this? If nobody is working on it I can put the time. Just let me know @roji

roji commented 2 years ago

@cfauchere I'm not aware of anyone working on this - you're welcome to do so. However, it would be good if you could submit a quick description of what you're planning to add (e.g. API) before starting work, so we can make sure we're in the right direction etc.

nikitasavinov commented 2 years ago

Hi @cfauchere I was planning to work on it after EF Core 6.0 release, but if you started/want to start - would be great! And if not and @roji you have now time for a design/PR review - I'm happy to move this forward.

My plan was based on this:

So this work would ideally happen for EF Core 7.0, and we'd have time to react to your design/PR starting from 2-3 months from now.

preardon commented 2 years ago

Is anyone working on this as yet, I'de be happy to help out

preardon commented 1 year ago

As above, I really need this in the mainline, I am happy to do the work, Just let me know if it needs to be done.

Can I please have an update

roji commented 1 year ago

As I wrote above, we'd welcome a contribution for this - but please submit an API design proposal first.

Also, since it's possible to add masking via raw SQL, the lack of specific support should not block anyone in any way. The number of possible migration tweaks is very large, and EF Core likely won't ever support absolutely everything; using raw SQL for to configure things is completely fine.

preardon commented 1 year ago

@roji I will submit an API design, Is there a deadline to have this in for EF 7?

roji commented 1 year ago

@preardon at this point it's rather late in the release, and it isn't sure we'll have enough bandwidth to give the PR the proper attention... But you can try...

preardon commented 1 year ago

@preardon at this point it's rather late in the release, and it isn't sure we'll have enough bandwidth to give the PR the proper attention... But you can try...

Sorry mate, if I had realised noone was working on it earlier I would have done it earlier

zyofeng commented 7 months ago

Anyone just looking at this? With latest ef core the lib no longer works.