Cheatsheets | code snippets , language cheatsheets | Learning library
kandi X-RAY | Cheatsheets Summary
kandi X-RAY | Cheatsheets Summary
A collection of code snippets, language cheatsheets, and development course notes updated as often as I can.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Cheatsheets
Cheatsheets Key Features
Cheatsheets Examples and Code Snippets
Community Discussions
Trending Discussions on Cheatsheets
QUESTION
For my studys i have to develope a web site that verify from a given url if this is vulnerable to DOM Based XSS and then print a report of what it found, i already read a lot of article and specifically this ones Description of xss Documentation on prevention Doc on prevention of DOM based
but i'm stucked in a point, which is :
...How can i inspect/analyze the dom of a page from a given url, from my web site (html/js/jquery)
ANSWER
Answered 2021-Jun-12 at 08:55The Same Origin Policy prevents this.
You'll need to find a different approach.
QUESTION
Scenario: As an Administrator I need to invalidate a user's session (log them out) after I update the user's password. This is in accordance with best practices as per https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html#Renew_the_Session_ID_After_Any_Privilege_Level_Change
I am using Devise and I saw here https://stackoverflow.com/a/45756884/664675 there is a config to log the user out: config.sign_in_after_reset_password = false
However, I have enabled this config in my devise.rb
but the user remains logged in. Not sure why that is?
I am also using Redis as the session_store
ANSWER
Answered 2021-Jun-02 at 07:12the flag sign_in_after_reset_password
does not relate to logout
user at all, sign_in_after_reset_password = false
imply that in case a user update his account password by himself then do not automatically sign-in his account again, and that logic happen only on PasswordsController#update.
So you as admin try to change password of another user in a custom controller, of course it's not logout user no matter the value of sign_in_after_reset_password
is.
devise
use gem warden
to logout
user (in other word: destroy user session) and warden
base on request session
not base on database
, that mean there's no way an admin can get another user's session to reset, so you can not force logout another user by only devise
, you need to handle this feature outside devise (such as add session
to user
table or a devise hook something like timeoutable)
QUESTION
I'm noticing some odd behavior with R regex quantifiers written as either {min, max}
(as recommend in the stringr cheatsheet) vs. as {min - max}
, when using the pointblank package. I expect the regexes to work with {min, max}
and fail with {min - max}
. However, in the two examples below, one works with {min, max}
and one works with {min - max}
.
Example 1 works as expected: pattern_comma
works and pattern_dash
does not. But example 2 works unexpectedly: doi_pattern_comma
does not work and doi_pattern_dash
does work.
Any suggestions about this regex? Or might this be a bug in pointblank (in which case I can open an issue there)?
Thank you, SO community!
...ANSWER
Answered 2021-May-09 at 21:52You must not doubt: {min-max}
quantifier does not exist, you need to use
{min,max}
. \d{4-9}
throws an exception (try it with sub
and you will get invalid regular expression '\d{4-9}', reason 'Invalid contents of {}'
).
Next, the second issue is that the regex is parsed with the default TRE regex engine, and you can't use shorthand character classes like \w
or \W
inside bracket expressions there, so you need to use [:alnum:]_
instead of \w
inside square brackets.
Now, that you know the right regex:
QUESTION
I am looking for a smooth way to change a ggplot2
output to grey level.
Here an example:
...ANSWER
Answered 2021-Jan-22 at 10:17I'm not quite sure where the confusion is coming from, as your intuition seems totally correct to me. When I use the scale_colour_grey()
is does exactly what you would expect and what you describe should be the outcome.
QUESTION
I'm building an iframe, not with innerHTML
, but with createElement
.. I have two untrusted strings that are used:
ANSWER
Answered 2020-Nov-22 at 21:52When working with the DOM, there are no html encoding issues in any element properties. The characters <
, >
, &
, "
, and '
do not need escaping.
However, you still need to deal with the semantics of the respective attribute. While title
is just a plain string that's not used for anything but displaying tooltips, others are not safe:
on…
event handlers contain javascript code. It's a bad practice to assign strings to them anyway, but if you do, interpolating values must follow javascript escaping rules.
⇨ Rule #3style
properties contain CSS rules which need their own escaping.
⇨ Rule #4src
orhref
attributes are urls that the browser will load at some point. Those definitely are sensitive, and when interpolating values into urls you need to follow URL encoding rules.
⇨ Rule #5- … (not meant to be exhaustive)
In your particular case, if you fail to url-encode the untrustedStr2
, the attacker may send arbitrary query parameters or fragments to example.com
. This is not a security issue in itself if example.com isn't susceptible to reflected XSS (the attacker may send the same link to the user via other channels), but it is broken functionality (undesired behaviour), but still it's your page endorsing the linked content.
So if untrustedStr2
is meant as a value of the id
URI query parameter, you should definitely use
QUESTION
Nuxt SSR app using FirebaseUI to handle auth flows. Logging in and out works perfectly. When I add Middleware to check auth state and redirect if not logged in I get this error:
Error: Redirected when going from "/list-cheatsheets" to "/login" via a navigation guard.
middleware/auth.js
...ANSWER
Answered 2020-Oct-29 at 23:10You can try
QUESTION
As per OWASP sesssion's must have an absolute timeout which defines the maximum amount of time a session can be active. I know how to set the max inactivity timeout for a spring session using server.servlet.session.timeout
however I am not sure how to set the absolute timeout for the session. I guess I could set the Max-Age
attribute for the Cookie which would potentially serve as an absolute timeout, however I was wondering if the absolute timeout could be somehow set on the server side session?
ANSWER
Answered 2020-Sep-08 at 05:18This feature is not implemented in Spring sessions. See https://github.com/spring-projects/spring-session/issues/922 for workaround.
QUESTION
I'm familiar with using templates in NodeJS like EJS to escape data for an HTML context.
However what would be the recommended way to safely output from an API? Given the intended usage is not known, it couldn't be escaped using HTML encoding.
Since I'm currently basically just doing res.json({})
for the output.
I'm thinking while some fields of incoming data can be validated (like 'email'), other fields that are more vague (like 'description') could contain any of the characters someone might use for XSS. Like < and ;. The options on OWASP seem limited https://cheatsheetseries.owasp.org/cheatsheets/Nodejs_Security_Cheat_Sheet.html Like this, but it was last updated 7 years ago https://github.com/ESAPI/node-esapi
Is it up to the recipient to handle? So if someone sends "alert(0);" as their description, I allow it through, as that is a valid JSON {"description":"alert(0);"}
...ANSWER
Answered 2020-Sep-05 at 19:43If someone wants to send in a description let them do so. They may have perfectly valid and legitimate reasons to do that. Perhaps they're writing an article about security and this is just an example of an XSS attack.
This isn't a threat to your database but to your web pages.
Security is neither a server-only nor a client-only job. It's a bit of both and the way you mitigate threats depends on the context.
When writing to a database, it's not XSS you have to worry about but things like SQL injection for example.
XSS is a threat for web applications and the way to mitigate that threat is to properly encode and/or escape any user-controlled input before it gets into the DOM.
QUESTION
I have an unordered list of list items containing elements for labels and values that are dynamically generated. I am trying to validate that the list contains a specific label with a specific value.
I am attempting to write an xpath that will allow me to find the parent element that contains the defined label and value with protractor's element(by.xpath). Given a list, I need to be able to find any single li by the combination of two descendants of specific attributes. For example, a li element that contains any descendent with class=label and text=Color AND any descendent with text=Blue.
...ANSWER
Answered 2020-Sep-02 at 13:02The reason you are getting invalid xPath is because:
The |, or union, operator returns the union of its two operands, which must be node-sets..
However since you have used inside one node you are getting issue. To meet your requirement below xpath will work just fine:
QUESTION
I'm looking at an R script that I found online related to fantasy football predictions, and the code is a little outdated so I'm trying to make it work for this season of the NFL. I am somewhat familiar with R but I don't know anything about HTML or PHP, and in order to gather the player's data I need the table from this URL: http://www.fantasypros.com/nfl/rankings/consensus-cheatsheets.php
This is the line of code that they used to extract the table, but it doesn't seem to work anymore.
experts <- data.table(readHTMLTable("http://www.fantasypros.com/nfl/rankings/consensus-cheatsheets.php", stringsAsFactors = FALSE)$data)
It simple says
Error: failed to load external entity "http://www.fantasypros.com/nfl/rankings/consensus-cheatsheets.php"
I've looked up different ways to pull tables out of a website, but they are all unique to that particular table. Any way I could get all of this data into a data frame in R?
...ANSWER
Answered 2020-Sep-01 at 21:46I've had the same problem and the easiest workaround I found for this issue is downloading the file before loading it into R.
Since you want to turn the HTML file into a table, the best solution is using readHTMLTable()
, then you'll load a list of data frames.
Here follows the code to solve it:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Cheatsheets
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page