rapidfsub
Here is a test code about my question.
https://github.com/rapidfsub/sonet/blob/develop/test/sonet_lib/ash/policies/common_test.exs#L92
And here is a resource code about my question.
https://github.com/rapidfsub/sonet/blob/develop/test/support/lib/sonet_lib/seven_eleven/product.ex
Brief overview about my test
- resource: Store, Inventory, Product
- actor: Customer
- actions:
Store.purchasecallsInventory.purchasethrumanage_relationship.
Inventory.purchasecallsProduct.purchasethrumanage_relationship. - policies:
Store.purchasechecks open and close time.
Inventory.purchasechecks inventory count.
Product.purchasechecks customer’s age.
Question
Product.purchase update action is an empty action with policies.
Even if it does nothing, but I want to check policies always.
-
With
require_atomic? falsein action, always check policies.
Without it, never check policies. Is this intended behavior? -
Using
require_atomic? falseto force policy check is weird,
and I foundaccess_type :strictforces policy check.
Empty action withaccess_type :filterskips policy check.
Is this intended behavior?
+ small questions (not related to content)
- How can I auto generate
postgres schemamigration? Should I write it manually?
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
zachdaniel
1 & 2: atomic actions don’t bypass policies. Could you describe the specific behavior that you’re seeing? What specifically makes you say that it’s not checking policies?
mix ash.codegen name_for_your_changes. Are you referring to something else there?rapidfsub
If I generate migration using
mix ash.codegen,I can see
prefix: "seven_eleven"in the generated code,but there is no
execute("CREATE SCHEMA seven_eleven").rapidfsub
You can easily reproduce it by running my test in above repository.
Here’s what I seeing.
Store.purchaseaction.Store.purchasecallsInventory.purchasethrumanage_relationship.Inventory.purchasecallsProduct.purchasethrumanage_relationship.Product.purchaselooks like below, policy check is skipped.If
Product.purchaselooks like below, policy check is not skipped.If I comment out
require_atomic? falsein myProduct.purchaseaction, the test fails.zachdaniel
Okay, I’ve identified the issue. It’s a very specific edge case. Its “skipping” the policy check in the case that an atomic action would induce no changes, however it’s important to note that it only does that when it is explicitly requested that no fields be updated (regardless of their initial value). So a very rare case (to call an update action that statically will not update any fields).
Aside from it being rare, I would not classify this as a security vulnerability because you can already see the record (thats how you’d be updating it in this way), and if an update were to actually happen, it would have been prevented.
Still, its confusing and problematic behavior, especially because it “presents” as if policies are being skipped, which is not a good thing.
zachdaniel
Ah, right. Yeah in this case you’ll want to alter the migrations by hand to generate the schema. We could add something into ensure they exist if we haven’t already, would be worth opening an issue in
ash_postgres.zachdaniel
Fixed in
ash_postgresversion2.4.10rapidfsub
Is it really that “rare” case?
I think policy can check resource’s own field only,
so empty action could be exist often for policy check.
Is there anything I can do instead of
Product.purchaseempty action in above example?rapidfsub
Can you tell me what is fixed exactly?
I cannot find anything related in ash_postgres changelog.
zachdaniel
This is from the changelog: “when an atomic update is fully skipped, run the query if it could produce errors”. You should see the difference by looking at what SQL queries are run in your reproduction.
It’s not that rare to have an action that can never update your own fields, but it’s rare to have one that can statically update none of its own fields and has side effects and is performed atomically. Actions called after the main resource action are authorized by their respective resource’s policies though, so any “nested” updates would be caught in a future check. Additionally most side effects like that prevent an action from being atomic without explicit action. I.e if you had added a before or after action hook, it would have required that you set
require_atomic? falsezachdaniel
I’m not sure I understand the question. Does upgrading AshPostgres not solve the issue?