Write an article or Share a link

How To Secure Deno From Malicious 3rd Party Code

Hints Staff
4 years ago
How To Secure Deno From Malicious 3rd Party Code by html hints

To keep app secure is always top priority. In this article i'm going to share with you a new security module for Deno know as permission-guard developed by Craig Morten.

This module is a zero-dependency, minimal permission guard for Deno to prevent overly permissive execution of your applications.


    import { guard } from "https://deno.land/x/permissionGuard@master/mod.ts";

    await guard();

    console.log("This is my code!");
                  

If the application is run with permissions it doesn't need, or without permissions it does need, the guard will shield your application and prevent it from running.

For example, the guard in the above example would prevent


    deno run --unstable -A ./index.ts
                  

from executing any further. This extra protection means you are safer from potential malicious 3rd party code that could otherwise take advantage of overly permission application executions.

#

Installation

Before getting through installation process make sure that you have installed & running you Deno application or you can go through this article Download And Install Deno to setup in your system.

Now, You can import permission-guard into your project:


    import { guard } from "https://deno.land/x/permissionGuard@master/mod.ts";
                  

If you want to use a specific version of permission-guard, just modify the import url to contain the version:


    import { guard } from "https://deno.land/x/permissionGuard@1.0.0/mod.ts";
                  

Or if you want to use a specific commit of permission-guard, just modify the import url to contain the commit hash:


    import { guard } from "https://deno.land/x/permissionGuard@22f4cc3/mod.ts";
                  
#

Features

  • 1. Protection against unnecessary top-level permissions.
  • 2. Protection against missing required permissions.
  • 3. Recommendations where permissions could be better scoped (if log: true provided).
  • 4. Useful logs detailing the missing or insecure permissions (if log: true provided).
#

Docs

  • 1. Docs - usually the best place when getting started
  • 2. Deno Docs
#

Examples

permission-guard has all the examples you need to get started.

To run the examples:

1. Clone the permission-guard repo locally:


      git clone git://github.com/asos-craigmorten/permission-guard.git --depth 1
   cd permission-guard
                  

Then run the example you want:


     deno run --unstable ./examples/defaults/index.ts
                  

We use cookies to ensure better User Experience. Read More