Skip to content

Commit 9fa1338

Browse files
authored
feat: update webpack plugin out of beta end minor refresh (#20)
* feat: update webpack plugin out of beta end minor refresh * lint fix
1 parent 012d656 commit 9fa1338

File tree

5 files changed

+17
-23
lines changed

5 files changed

+17
-23
lines changed

astro.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default defineConfig({
2929
link: '/guides/webpack',
3030
},
3131
{ label: 'Policy files', link: '/guides/policy' },
32+
{ label: 'Reviewing policy', link: '/guides/policy-diff' },
3233
{
3334
label: 'Troubleshooting Common Problems',
3435
link: '/guides/troubleshooting',

src/content/docs/guides/getting-started.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ sidebar:
99

1010
LavaMoat is distributed as a [Node.js][node] command-line tool. You'll need an LTS version of Node.js:
1111

12-
- Node.js v20.0.0 (recommended) _or_
13-
- Node.js v16.20.0 (minimum)
12+
- Node.js LTS (recommended) _or_
13+
- Node.js v18 (minimum)
1414

1515
:::tip
1616

@@ -22,7 +22,7 @@ Don't have Node.js installed? [Download and install Node.js from the official si
2222

2323
1. Control dependency lifecycle scripts (eg. "postinstall") via [@lavamoat/allow-scripts][lavamoat-allowscripts]
2424
2. Run your server or build process in [lavamoat-node][lavamoat-node]
25-
3. Build your ui with our [Webpack5 plugin (beta)][lavamoat-webpack] or use LavaMoat for [Browserify][lavamoat-browserify]
25+
3. Build your ui with our [Webpack5 plugin][lavamoat-webpack] or use LavaMoat for [Browserify][lavamoat-browserify]
2626

2727
:::tip
2828

src/content/docs/guides/lavamoat-node.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: 'A user guide for running LavaMoat-protected NodeJS applications'
77

88
:::caution
99

10-
This runtime does not support ESM modules. A new runtime that's ESM-first is a work in progress.
10+
This runtime does not support ESM modules. A new runtime that's ESM-first is a work in progress. You can try it out by installing `@lavamoat/node`.
1111

1212
:::
1313

src/content/docs/guides/webpack.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,10 @@ title: 'lavamoat and webpack'
33
description: 'A user guide for adding LavaMoat protections to a webpack bundle'
44
---
55

6-
TODO: make it more like a guide and less like just a readme.
7-
8-
LavaMoat Webpack Plugin wraps each module in the bundle in a [SES Compartment](https://github.com/endojs/endo/tree/master/packages/ses#compartment) and enforces a Policy independently per package.
9-
10-
:::Note[Beta]
11-
LavaMoat Webpack plugin is currently in [Open Beta](https://github.com/LavaMoat/LavaMoat/discussions/723). It's pretty stable at this point, but breaking changes may still happen.
12-
:::
6+
LavaMoat Webpack Plugin wraps each module in the bundle in a [Compartment](https://hardenedjs.org/#compartment) and enforces a Policy independently per package.
137

148
:::Note
15-
LavaMoat Webpack plugin does not support advanced features relying on dynamic chunk loading including Module Federation and Hot Module Reloading.
9+
LavaMoat Webpack plugin does not support some features relying on dynamic module loading and overwriting, including Module Federation and Hot Module Reloading.
1610
:::
1711

1812
## Usage
@@ -21,15 +15,13 @@ LavaMoat Webpack plugin does not support advanced features relying on dynamic ch
2115

2216
```shell
2317
npm i -D @lavamoat/webpack
24-
# or
25-
# yarn add -D @lavamoat/webpack
2618
```
2719

2820
1. Create a webpack bundle with the LavaMoat plugin enabled and the `generatePolicy` flag set to true
2921
2. Make sure you add a `<script src="./lockdown"></script>` before all other scripts or enable the `HtmlWebpackPluginInterop` option if you're using `html-webpack-plugin`. (Note there's no `.js` there because it's the only way to prevent webpack from minifying the file thus undermining its security guarantees)
3022
3. Tweak the policy if needed with policy-override.json
3123

32-
:::Note[Beta]
24+
:::Note
3325
Policy generation might still get confused about aliases and custom resolvers. Please report n issue if that occurs.
3426
:::
3527

@@ -101,17 +93,14 @@ The LavaMoat plugin takes an options object with the following properties (all o
10193
| `readableResourceIds` | Boolean to decide whether to keep resource IDs human readable (possibly regardless of production/development mode). If `false`, they are replaced with a sequence of numbers. Keeping them readable may be useful for debugging when a policy violation error is thrown. By default, follows the Webpack config mode. | `(mode==='development')` |
10294
| `lockdown` | Configuration for [SES lockdown][]. Setting the option replaces defaults from LavaMoat. | reasonable defaults |
10395
| `HtmlWebpackPluginInterop` | Boolean to add a script tag to the HTML output for `./lockdown` file if `HtmlWebpackPlugin` is in use. | `false` |
104-
| `inlineLockdown` | Array of output filenames in which to inline lockdown (instead of adding it as a file to the output directory). | |
96+
| `inlineLockdown` | A RegExp for matching files to be prepended with lockdown (instead of adding it as a file to the output directory). | |
10597
| `runChecks` | Boolean property to indicate whether to check resulting code with wrapping for correctness. | `false` |
106-
| `diagnosticsVerbosity` | Number property to represent diagnostics output verbosity. A larger number means more overwhelming diagnostics output. Setting a positive verbosity will enable `runChecks`. | `0` |
98+
| `diagnosticsVerbosity` | Number property to represent diagnostics output verbosity. A larger number means more overwhelming diagnostics output. | `0` |
99+
| `debugRuntime` | Only for local debugging use - Enables debugging tools that help detect gaps in generated policy and add missing entries to overrides | `false` |
107100
| `policy` | The LavaMoat policy object (if not loading from file; see `policyLocation`) | `undefined` |
108101

109102
### Excluding modules
110103

111-
:::Caution
112-
This is an experimental feature and excluding may be configured differently in the future if this approach is proven insecure.
113-
:::
114-
115104
The default way to define specific behaviors for webpack is creating module rules. To ensure exclude rules are applied on the same exact files that match certain rules (the same RegExp may be matched against different things at different times) we're providing the exclude functionality as a loader you can add to the list of existing loaders or use individually.
116105
The loader is available as `LavaMoatPlugin.exclude` from the default export of the plugin. It doesn't do anything to the code, but its presence is detected and treated as a mark on the file. Any file that's been processed by `LavaMoatPlugin.exclude` will not be wrapped in a Compartment.
117106

@@ -166,6 +155,10 @@ Sadly, even tree shaking doesn't eliminate that module. It's left there and fail
166155

167156
This plugin will skip policy enforcement for such ignored modules so that they do not have to be explicitly listed in the policy file.
168157

158+
#### Ambient assets
159+
160+
Whenever webpack finds `new URL('./existing/path/to/file')` in the code it turns that file into an asset in your output folder by default. LavaMoat disables that for files requested from node_modules.
161+
169162
## Security
170163

171164
**This is an experimental software. Use at your own risk!**

src/content/docs/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ import { YouTube } from 'astro-embed';
4141
<Card>
4242
Made with 🧡 by [MetaMask](https://github.com/metamask/)
4343

44-
Funded by [ConsenSys](https://github.com/consensys)
44+
Funded by [Consensys](https://github.com/consensys)
4545

46-
Runs on [Agoric](https://github.com/agoric/) technology
46+
Runs on [Hardened JavaScript](https://hardenedjs.org/) technology
4747

4848
</Card>
4949

0 commit comments

Comments
 (0)