-
Notifications
You must be signed in to change notification settings - Fork 4
Jc/fix code smells #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
69d88f5
9dc48c1
80b2efd
b97b8e4
8b41a2c
6d87a30
0cef15f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,6 @@ import {BrowserTypes} from '../types/actionTypes'; | |
| import {WindowState} from '../types/BrowserState'; | ||
| import Action from '../types/redux'; | ||
|
|
||
| // Code smell on this function signature | ||
| function windowSize(state: WindowState = {height: NaN, width: NaN}, action: Action) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is how redux is designed to be used, this code smell needs to be disabled
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from what I see it is just saying to put the defaults at the end.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Jason is right, if you try to flip it, it breaks redux. I marked this as a false positive. |
||
| if (action.type === BrowserTypes.SCREEN_RESIZE) { | ||
| return { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,17 +9,16 @@ import {persistGlobalStore, persistRootReducer} from './persistance'; | |
|
|
||
| const configureStore = (initialState?: DeepPartial<WebState>, onReady?: () => void) => { | ||
| const root = persistRootReducer(combineReducers(rootReducer(history))); | ||
| // @ts-ignore | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This used to break without ts-ignore, it doesn't any more?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, it was working when I opened this PR. But now I've merged dev in and the linter is mad, so I'm not sure what changed. Either way I'll just put it back. |
||
| const composeEnhancers: typeof compose = (typeof window !== 'undefined' && window['__REDUX_DEVTOOLS_EXTENSION_COMPOSE__']) || compose; | ||
| const storeInstance = createStore( | ||
| root, | ||
| initialState, | ||
| // Code smell on this | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is completely false, it does change the type expressions and is necessary
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that's why I removed this comment. I was using the comments to help me keep track of what code smells I hadn't fixed yet. Once I realized this was a false positive I removed the comment and marked the smell resolved. |
||
| composeEnhancers(applyMiddleware(thunk as ThunkMiddleware<WebState, AnyAction>, routerMiddleware(history))) | ||
| ); | ||
| const persistorInstance = persistGlobalStore(storeInstance, onReady); | ||
| storeInstance.dispatch(initBrowser()); | ||
| return { store: storeInstance, persistor: persistorInstance, appDispatch: storeInstance.dispatch}; | ||
| }; | ||
|
|
||
| // @ts-ignore | ||
| export const {store, persistor, appDispatch } = configureStore(); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasekiw @Cliftonz Sonarcloud thinks this is a security issue because we aren't verifying the origin of the message that we're listening to. But this is a reference to a window that we opened ourselves, so I don't think there's any real security risk here? I could be wrong, just wanted to check before I marked the issue resolved on Sonarcloud.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone could intercept our call back to a users and put their own vnc messages in there.
I remember talking about this with Jason but I do not remember what we decided on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally the solution is to just verify the event origin, which I tried, but the BeforeUnloadEvent type that we're using doesn't seem to have a origin property. So I'm not sure what the proper solution here would be, at least not without some significant refactoring.
Let's see if Jason has any ideas, he built this component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cliftonz How could someone intercept our callback? They would have to do cross site scripting which would be an even worse exploit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Cliftonz We're talking about an event handler that asks the user if they are sure if they want to exit, how much damage could exploiting this method really do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasekiw I'm with you here, I think. I can mark this as won't fix if you're okay with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are ok with this