martes, 24 de marzo de 2015
martes, 17 de marzo de 2015
Secure cookies of being accessed from javascript
Look, if type document.cookie on the browser console i get the current cookies an its values
If you want to secure your cookies of being accessed from javascript you can use de HttpOnly flag
Now, here is the code:If the HttpOnly flag (optional) is included in the HTTP response header, the cookie cannot be accessed through client side script (again if the browser supports this flag). As a result, even if a cross-site scripting (XSS) flaw exists, and a user accidentally accesses a link that exploits this flaw, the browser (primarily Internet Explorer) will not reveal the cookie to a third party.If a browser does not support HttpOnly and a website attempts to set an HttpOnly cookie, the HttpOnly flag will be ignored by the browser, thus creating a traditional, script accessible cookie. As a result, the cookie (typically your session cookie) becomes vulnerable to theft of modification by malicious script
java
Cookie cookie = getMyCookie("myCookieName");
cookie.setHttpOnly(true);
Web.config (.NET)
This one has the advantage that is applaied to all site cookies, not just the one explicity set
<system.web> <httpCookies httpOnlyCookies="true"/> </system.web>
c#
HttpCookie cookie = new HttpCookie(key, value); cookie.HttpOnly = true;
Now, our cookies are safer
I hope this help you
lunes, 16 de marzo de 2015
Publish Visual Studio proyect from command line
Maybe, you need to set up an automatic build-publish-deploy proccess therefore publishing a visual studio proyect from command line is a must. It can be done very easiley with the following command:
[path to msbuild] "[path to .csproj file]" /p:Configuration=[Debug|Release|Other you created] /p:DeployOnBuild=true /p:PublishProfile=[project publish profile name]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild "%~dp0AppFolder/MyProject.csproj" /p:Configuration=Production /p:DeployOnBuild=true /p:PublishProfile=Production_Profile
NOTE: Due i am using a .bat file to executie my command, i use the %~dp0 "trick" that is replaced with the current path of the .bat file achieving a portable "deployer" script

Now, if you execute the .bat you will get something like this
[path to msbuild] "[path to .csproj file]" /p:Configuration=[Debug|Release|Other you created] /p:DeployOnBuild=true /p:PublishProfile=[project publish profile name]
e.g.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild "%~dp0AppFolder/MyProject.csproj" /p:Configuration=Production /p:DeployOnBuild=true /p:PublishProfile=Production_Profile
NOTE: Due i am using a .bat file to executie my command, i use the %~dp0 "trick" that is replaced with the current path of the .bat file achieving a portable "deployer" script
The trick.bat has the following code:
echo %~dp0
pause
The output wil be
Now, if you execute the .bat you will get something like this
Suscribirse a:
Entradas (Atom)
