Skip to content

Commit

Permalink
Merge pull request #167 from NearSocial/release-2.5.5
Browse files Browse the repository at this point in the history
## 2.5.5

- FIX: Restrict attributes of `Files` component to a whitelist. Reported by BrunoModificato from OtterSec.
  • Loading branch information
evgenykuzyakov committed Jan 8, 2024
2 parents e9e6173 + d44aad3 commit d8eb167
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.5.5

- FIX: Restrict attributes of `Files` component to a whitelist. Reported by BrunoModificato from OtterSec.

## 2.5.4

- Added optional `commitModalBypass` feature config. When the `<CommitButton />` component is used inside of a widget with a matching `src` prop, the `CommitModal` will be bypassed and `onCommit()` will be called instantly when the button is clicked. If for some reason the requested transaction is invalid, the `CommitModal` will still appear to show an error message to the user. View example below to see configuration options.
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "near-social-vm",
"version": "2.5.4",
"version": "2.5.5",
"description": "Near Social VM",
"main": "dist/index.js",
"files": [
Expand Down
29 changes: 27 additions & 2 deletions src/lib/vm/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,31 @@ const requirePattern = (id) => {
}
};

const FilesComponentWhitelist = [
"key",
"name",
"className",
"onChange",
"onError",
"accepts",
"multiple",
"clickable",
"maxFiles",
"maxFileSize",
"minFileSize",
"dragActiveClassName",
];

const filterFilesAttributes = (attributes) => {
const filteredAttributes = {};
FilesComponentWhitelist.forEach((key) => {
if (attributes.hasOwnProperty(key)) {
filteredAttributes[key] = attributes[key];
}
});
return filteredAttributes;
};

class Stack {
constructor(prevStack, state) {
this.prevStack = prevStack;
Expand Down Expand Up @@ -688,7 +713,7 @@ class VmStack {
accepts={["image/*"]}
minFileSize={1}
clickable
{...attributes}
{...filterFilesAttributes(attributes)}
>
{status.img?.uploading ? (
<>{Loading} Uploading</>
Expand All @@ -701,7 +726,7 @@ class VmStack {
</div>
);
} else if (element === "Files") {
return <Files {...attributes}>{children}</Files>;
return <Files {...filterFilesAttributes(attributes)}>{children}</Files>;
} else if (element === "iframe") {
return <SecureIframe {...attributes} />;
} else if (element === "Web3Connect") {
Expand Down

0 comments on commit d8eb167

Please sign in to comment.