Git Product home page Git Product logo

ds-guard's Introduction

DSGuard

Permissions whitelist with address-level granularity

Manages an Access Control List which maps source and destination addresses to function signatures. Intended to be used as an authority for ds-auth where it acts as a lookup table for the canCall function to provide boolean answers as to whether a particular address is authorized to call agiven function at another address.

The acl is a mapping of [src][dst][sig] => boolean where an address src can be either permitted or forbidden access to a function sig at address dst according to the boolean value. When used as an authority by DSAuth the src is considered to be the msg.sender, the dst is the including contract and sig is the function which invoked the auth modifier.

// Permit a specific address to call a specific function on a specific contract
src = '0011111111111111111111111111111111111111'
dst = '0022222222222222222222222222222222222222'
guard.permit(src, dst, bytes4(sha3('mint(address,uint256)')));

The ANY constant can be stored in place of src, dst or sig where it will act as a wildcard and be considered to match any item in that position.

// Permit ANY address to call a specific function on a specific contract
guard.permit(ANY, dst, bytes4(sha3('mint(address,uint256)')));

// Permit ANY address to call a ANY function on a specific contract
guard.permit(ANY, dst, ANY);

Warning: Statements in the access control list are evaluated with the OR operator, meaning that the most open permission will take precedence. If all of the the above 3 examples were in place for example, it is the last that would take precedence, regardless of the more restrictive permissions defined prior. Developers are encouraged to think carefully before using ANY.

Actions

permit

permit an address to call a function at a contract (requires auth)

forbid

forbid an address from calling a function at a contract (requires auth)

ds-guard's People

Contributors

apmilen avatar d-xo avatar dbrock avatar desaperados avatar livnev avatar mbrock avatar nanexcool avatar nmushegian avatar rainbreak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ds-guard's Issues

sig collision?

Looks like ANY trick is fine for src/dest, but is there some fuckery that could happen with a malicious function signature bytes4(uint32(-1))? @dbrock

Won’t compile with Solidity 0.6

I get the following error: “TypeError: Overriding function is missing "override" specifier” for the function canCall, which is overriding the one in DSAuthority.

Guard by Default

Would it not be cleaner and use 1 less mapping if we were to set a default state variable, for example, defaultGuard = True
Then you only need to maintain a single list of excaptions to the default,
so if the default is Guard unless allowed, then the mapping would contain a white list, if the status is Allow, then it would be a black list.
Of course, having more states than a single logic would work, I just feel having 2 address arrays is additional storage that is not space efficient, and what would happen if a Single address managed to get into both lists? My years of development have taught me to only have single source of truth.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.