Create action does not honor database policy
See original GitHub issueIn the current version the create
action does not honor the specified database policy, which means that a request can create a new row in the database even if that row is outside the scope of the defined policy for that request. For example if I have the following entity:
"Todo": {
"source": {
"object": "dbo.todos",
"type": "table"
},
"rest": {
"path": "todo"
},
"permissions": [
{
"role": "anonymous",
"actions": [
{
"action": "*",
"policy": {
"database": "@item.owner_id eq 'public'"
}
}
]
}
]
}
I should not be able to send a POST request like the following:
curl --request POST \
--url https://localhost:5001/api/todo \
--header 'Content-Type: application/json' \
--data '{
"title": "Testing policy",
"completed": false,
"owner_id": "hack!"
}'
but of course it works right now as the generate INSERT statement is the following:
INSERT INTO [dbo].[todos] ([title], [completed], [owner_id])
OUTPUT Inserted.[id], Inserted.[title], Inserted.[completed], Inserted.[owner_id]
VALUES (@param0, @param1, @param2);
my proposal is to change the way the INSERT is generated so that DAB will generate the following SQL statement:
INSERT INTO [dbo].[todos] ([title], [completed], [owner_id])
OUTPUT Inserted.[id], Inserted.[title], Inserted.[completed], Inserted.[owner_id]
SELECT [title], [completed], [owner_id]
FROM (VALUES (@param0, @param1, @param2)) T([title], [completed], [owner_id])
WHERE [owner_id] = @param_from_policy
so that all values that are not compatible with the policy will be filtered out by the WHERE clause (as it happens for other statements)
Issue Analytics
- State:
- Created 7 months ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Provision access by data owner for Azure SQL Database ...
This guide covers how a data owner can delegate authoring policies in Microsoft Purview to enable access to Azure SQL Database. The following ......
Read more >Classic Business rules
A business rule is a server-side script that runs when a record is displayed, ... Business rules do not honor ACLs until you...
Read more >15 Recovery Appliance Error Message Reference
Cause : An attempt was made to move the specified database to a new storage location, but the database could not be shrunk...
Read more >Honor “Do Not Share” and "Do Not Sell" Requests in Data ...
Create a custom field in the Individual DMO to store Do Not Share or Do Not Sell request data. Map your Do Not...
Read more >ACM Code of Ethics and Professional Conduct
1.4 Be fair and take action not to discriminate. 1.5 Respect the work required to produce new ideas, inventions, creative works, and computing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@seantleonard Lets document this in your PR: #1215 that database policy is not supported for
create
actionYeah, I didn’t mean like a physical temporary table - but more like conceptual. Meant to say like a result set.