Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Tuesday, October 31, 2017

JS Frameworks with Salesforce

As I mentioned on previous entries, Salesforce has its good and bad things, but coming from a Java School, I still firmly believe that is not very Developer Friendly.

One of the things I wanted to try was to implement a Rich UI using JavaScript frameworks and either simple backend or APIs. However, Salesforce makes it kind of complicated.

The main challenge is around managing static resources, since all your code will be mostly in a bunch of JS files which have to be packaged and deployed in a Zip file as static resource.
But if you are patient enough you could implement something cool with a Visualforce page that might look like this:

On this particular approach we mixed Apex Remote Objects (Remote Object Model) with React. But that doesn't mean that you can't be creative and go for something more complex like using @RemoteAction in your controller methods.

Yeah, we could have tried something more Salesforcy like Lightning, but that's not what the cool kids use nowadays :D

Thursday, August 8, 2013

Modify iframe contents with Javascript

Conventionally, you are not allowed to play around with the contents of an iframe of external url with javascript. But with the use of javascript injections, you can do it very easily.
For example, you want to modify the values of text fields in the web page open in an iframe, but the web page is from an external url. What you would have tried first would have been:

But this does not work when you open the web page in a browser. So what to do? Let’s explore the possibilities of doing this with JavaScript Injections.
We know that we have the full permissions to modify the url of an iframe. So what we do is,
And viola! The username is changed!

Applications:
Possible applications of such injections are:
  • Automatic form filling Modifying the contents of iframe with
  • Automatic login by using
  • Automatic posting/commenting on sites like facebook, wordpress blogs, etc.
  • Or you can go further and insert a full javascript file into the external web page with:


Examples: Anything else you can imagine of!


Friday, May 20, 2011

Cross-site Scripting (XSS)

Cross-Site Scripting attacks are a type of injection problem, in which malicious scripts are injected into the otherwise benign and trusted web sites. Cross-site scripting (XSS) attacks occur when an attacker uses a web application to send malicious code, generally in the form of a browser side script, to a different end user. Flaws that allow these attacks to succeed are quite widespread and occur anywhere a web application uses input from a user in the output it generates without validating or encoding it.

An attacker can use XSS to send a malicious script to an unsuspecting user. The end user’s browser has no way to know that the script should not be trusted, and will execute the script. Because it thinks the script came from a trusted source, the malicious script can access any cookies, session tokens, or other sensitive information retained by your browser and used with that site. These scripts can even rewrite the content of the HTML page.

The normal practice is to HTML-escape any user-controlled data during redisplaying in JSP, not during processing the submitted data in servlet nor during storing in DB. In JSP you can use the JSTL (to install it, just drop jstl-1.2.jar in /WEB-INF/lib) <c:out> tag or fn:escapeXml function for this. E.g.

OR
This is the classic example: Look carefully to the param authtype, did you see the alert(1)??? If you don't write safe code, you might get an infinite loop in your screen :)

For more details please go to: https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)