Skip to content

Commit

Permalink
fix: unsafe eval in function constructor #35
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlescure committed Oct 16, 2020
1 parent 8986522 commit 00b3de6
Show file tree
Hide file tree
Showing 15 changed files with 338 additions and 60 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: tests

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
# events but only for the main branch
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"deno.enable": true,
"typescript.tsdk": "node_modules/typescript/lib"
"typescript.tsdk": "node_modules/typescript/lib",
"god.tsconfig": "./tsconfig.json"
}
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@

Generate random or sequential UUID of any length.

This project is open to updates by its users, I ensure that PRs are relevant to the community.
In other words, if you find a bug or want a new feature, please help us by becoming one of the
[contributors](#contributors-) ✌️ ! See the [contributing section](#contributing).

## Like this module? :heart:

Please consider:

- [Buying me a coffee](https://www.buymeacoffee.com/jeanlescure) :coffee:
- Supporting me on [Patreon](https://www.patreon.com/jeanlescure) :trophy:
- Starring this repo on [Github](https://github.com/jeanlescure/string-crypto) :star2:

### Use as module

```js
Expand Down Expand Up @@ -167,6 +179,11 @@ yarn dist:build

**IMPORTANT**: The `dist:build` script depends on the files generated by `lib:build`.

## Contributing

Yes, thank you! This plugin is community-driven, most of its features are from different authors.
Please update the docs and tests and add your name to the `package.json` file.

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Expand Down Expand Up @@ -197,5 +214,5 @@ This project follows the [all-contributors](https://github.com/all-contributors/

## License

Copyright (c) 2018-2020 [Short Unique ID Contributors](https://github.com/jeanlescure/short-unique-id/graphs/contributors).<br/>
Copyright (c) 2018-2020 [Short Unique ID Contributors](https://github.com/jeanlescure/short-unique-id/#contributors-).<br/>
Licensed under the Apache License 2.0.
111 changes: 111 additions & 0 deletions assets/cookie-policy/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.concisecss.com/concise.min.css">
<link rel="stylesheet" href="https://cdn.concisecss.com/concise-ui/concise-ui.min.css">
<link rel="stylesheet" href="https://cdn.concisecss.com/concise-utils/concise-utils.min.css">
<title>Short Unique Id - Cookie Policy</title>
</head>
<body>
<div container class="_mtxs _mbxs">
<div class="card-box _mbxs">
<div class="card-content">
<p class="content">
<a href="/">&lt; Back</a>
</p>
</div>
</div>
<div class="card-box _mbxs">
<div class="card-content">
<h1 class="title _ts4">Cookie policy</h1>
<h2 class="_ts2 _c-text-secondary">Understand how we use cookies.</h2>
</div>
</div>
<div class="card-box _mbxs">
<div class="card-content">
<h3 class="title _ts3">What are cookies</h3>
<p class="content">
As is common practice with almost all professional websites this site uses cookies, which
are tiny files that are downloaded to your computer, to improve your experience.
This page describes what information they gather, how we use it and why we sometimes need
to store these cookies. We will also share how you can prevent these cookies from being
stored however this may downgrade or "break" certain elements of the sites functionality.
</p>
</div>
</div>
<div class="card-box _mbxs">
<div class="card-content">
<h3 class="title _ts3">How we use cookies</h3>
<p class="content">
We use cookies for a variety of reasons detailed below. Unfortunately in most cases there
are no industry standard options for disabling cookies without completely disabling the
functionality and features they add to this site. It is recommended that you leave on all
cookies if you are not sure whether you need them or not in case they are used to provide
a service that you use.
</p>
</div>
</div>
<div class="card-box _mbxs">
<div class="card-content">
<h3 class="title _ts3">Disabling cookies</h3>
<p class="content">
You can prevent the setting of cookies by adjusting the settings on your browser
(see your browser Help for how to do this). Be aware that disabling cookies will affect
the functionality of this and many other websites that you visit. Disabling cookies will
usually result in also disabling certain functionality and features of the this site.
Therefore it is recommended that you do not disable cookies.
</p>
</div>
</div>
<div class="card-box _mbs">
<div class="card-content">
<h3 class="title _ts3 _mbs">The cookies we set</h3>
<h4 class="_ts2">Site preference cookies</h4>
<p class="content _mbs">
In order to provide you with a great experience on this site we provide the functionality
to set your preferences for how this site runs when you use it. In order to remember your
preferences we need to set cookies so that this information can be called whenever you
interact with a page is affected by your preferences.
</p>
<h4 class="_ts2">Third party cookies</h4>
<p class="content _mbs">
In some special cases we also use cookies provided by trusted third parties.
The following section details which third party cookies you might encounter through this site.
</p>
<h4 class="_ts2">Google Analytics cookies</h4>
<p class="content">
This site uses Google Analytics which is one of the most widespread and trusted analytics
solutions on the web, as well as Hotjar in order to help us understand how you use the
site and ways that we can improve your experience. These cookies may track things such as
how long you spend on the site and the pages that you visit so we can continue to produce
engaging content.
</p>
<p class="content">
For more information on Google Analytics cookies, see the official <a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/cookie-usage">Google Analytics page</a>.
</p>
</div>
</div>
<div class="card-box _mbxs">
<div class="card-content">
<h3 class="title _ts3">More information</h3>
<p class="content">
Hopefully that has clarified things for you and as was previously mentioned if there is
something that you aren't sure whether you need or not it's usually safer to leave
cookies enabled in case it does interact with one of the features you use on our site.
However if you are still looking for more information then you can contact us via email
at <a href="mailto:[email protected]">[email protected]</a>.
</p>
</div>
</div>
<div class="card-box _mbxs">
<div class="card-content">
<p class="content">
<a href="/">&lt; Back</a>
</p>
</div>
</div>
</div>
</body>
</html>
13 changes: 4 additions & 9 deletions dist/short-unique-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ System.register("version", [], function (exports_1, context_1) {
return {
setters: [],
execute: function () {
exports_1("default", '3.0.4');
exports_1("default", '3.0.5');
}
};
});
Expand Down Expand Up @@ -141,7 +141,7 @@ System.register("mod", ["version"], function (exports_2, context_2) {
};
ShortUniqueId = class ShortUniqueId extends Function {
constructor(argOptions = {}) {
super('...args', 'return this.randomUUID(...args)');
super();
this.dictIndex = 0;
this.dictRange = [];
this.lowerBound = 0;
Expand Down Expand Up @@ -183,14 +183,9 @@ System.register("mod", ["version"], function (exports_2, context_2) {
this.debug = options.debug;
this.log(this.dict);
this.log((`Generator instantiated with Dictionary Size ${this.dictLength}`));
const instance = this.bind(this);
Object.getOwnPropertyNames(this).forEach((prop) => {
if (!(/arguments|caller|callee|length|name|prototype/).test(prop)) {
const propKey = prop;
instance[prop] = this[propKey];
}
return new Proxy(this, {
apply: (target, that, args) => this.randomUUID(...args),
});
return instance;
}
log(...args) {
const finalArgs = [...args];
Expand Down
2 changes: 1 addition & 1 deletion dist/short-unique-id.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions docs/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -2717,11 +2717,24 @@ ul.tsd-type-parameters .tsd-comment {
right: 0;
left: 0;
margin: 0;
padding: 50px;
background: #4da6ff;
padding: 0;
display: none;
z-index: 100;
}
.tsd-page-cookieconsent .message::before {
content: "";
opacity: 0.85;
background: #000;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
.tsd-page-cookieconsent .message {
padding: 40px;
}
.tsd-page-cookieconsent.show {
display: block;
}
Expand Down Expand Up @@ -2899,8 +2912,9 @@ input[type=checkbox]:checked + .tsd-widget:before {
}

@media (prefers-color-scheme: dark) {
.tsd-page-cookieconsent {
background: #4da6ff;
.tsd-page-cookieconsent .message::before {
opacity: 0.85;
background: #000;
}

.tsd-page-toolbar {
Expand Down
Loading

0 comments on commit 00b3de6

Please sign in to comment.