<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2020-12-14T03:47:17+00:00</updated><id>/feed.xml</id><title type="html">Stew Polley Coding</title><subtitle>Write an awesome description for your new site here. You can edit this line in _config.yml. It will appear in your document head meta (for Google search results) and in your feed.xml site description.</subtitle><entry><title type="html">Scripts to help setup your server</title><link href="/2018/02/25/scripts-to-help-setup-your-server/" rel="alternate" type="text/html" title="Scripts to help setup your server" /><published>2018-02-24T21:17:48+00:00</published><updated>2018-02-24T21:17:48+00:00</updated><id>/2018/02/25/scripts-to-help-setup-your-server</id><content type="html" xml:base="/2018/02/25/scripts-to-help-setup-your-server/">&lt;p&gt;Setting up your server to be correctly configured to accept traffic and proxy it back to the correct applications can be difficult at times.&lt;/p&gt;

&lt;p&gt;Ok it’s not really &lt;em&gt;that&lt;/em&gt; difficult, especially with &lt;a href=&quot;https://www.digitalocean.com/community/tutorials&quot;&gt;Digital ocean providing lovely guides&lt;/a&gt; for free on basicaly… anything!&lt;/p&gt;

&lt;p&gt;But these can take time to get setup, which is why a number of automated tools exist. Mainly for a learning excercise for myself, I wanted to build my own automation to get the type of servers I was commonly using quickly set up, to help improve my own productivity.&lt;/p&gt;

&lt;p&gt;So far I’ve written two main scripts, but will expand on these in time:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;LEMP stack setup&lt;/li&gt;
  &lt;li&gt;WordPress install&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can view the detailed instructions for these scripts at https://scripts.stewpolley.com/ and &lt;a href=&quot;https://github.com/StewPoll/deploy-scripts&quot;&gt;view the source code on github&lt;/a&gt;.&lt;/p&gt;</content><author><name>Stewart Polley</name></author><category term="PHP" /><category term="Python" /><category term="Security" /><summary type="html">Setting up your server to be correctly configured to accept traffic and proxy it back to the correct applications can be difficult at times.</summary></entry><entry><title type="html">What I was reading – Jan 2018 Edition</title><link href="/2018/02/01/what-i-read-am-reading-jan-2018-edition/" rel="alternate" type="text/html" title="What I was reading – Jan 2018 Edition" /><published>2018-01-31T20:00:16+00:00</published><updated>2018-01-31T20:00:16+00:00</updated><id>/2018/02/01/what-i-read-am-reading-jan-2018-edition</id><content type="html" xml:base="/2018/02/01/what-i-read-am-reading-jan-2018-edition/">&lt;p&gt;Welcome to the first monthly edition of my “What I’m reading” series. Click here to read other posts in this series.&lt;/p&gt;

&lt;p&gt;I’ve been compiling this list throughout January, and the following links appear in the chronological order of when I read them. Unlike my “Year in review” post, I’ll be posting links to &lt;em&gt;what I read&lt;/em&gt; this month, not to things that were published this month.&lt;/p&gt;

&lt;p&gt;Without further ado, here’s my reading list for Jan 2018.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://bugbountyguide.com/&quot;&gt;Bug Bounty Guide&lt;/a&gt;: Tips for Bug Hunters and Product Owners alike on how to hunt for bugs, and how to operate a bug bounty system.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://blog.appcanary.com/2017/http-security-headers.html&quot;&gt;Everything you need to know about HTTP security headers&lt;/a&gt;: A run down on the different HTTP security headers you can use, what they do, and instructions on how to set them in a number of frameworks/servers&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/irekrog/accessibility-checklist/blob/master/README.md&quot;&gt;Accessibility Checklist&lt;/a&gt;: A look at making sure your web-pages are designed in a way to allow those with accessibility needs can easily navigate your site.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://slack.engineering/android-ui-automation-part-1-building-trust-de3deb1c5995?source=rss----58820b6d8904---4&quot;&gt;Android UI Automation&lt;/a&gt;: This series by the Slack Engineering team is an interesting look into how they get their UI testing done, and why they feel it’s valuable.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://medium.freecodecamp.org/disabling-browser-incognito-check-cc84288e89b3&quot;&gt;Outsmarting Icognito Detection&lt;/a&gt;: Sites are trying to force you to not use incognito, so they can track you. This post looks at one way of how to get around that.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://xkcd.com/1938/&quot;&gt;xkcd: Meltdown and Spectre&lt;/a&gt;: One of the shortest and easiest to understand summaries of the whole Meltdown/Spectre incident.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://navytitanium.github.io/DNSMasterChef/&quot;&gt;Setting up a DNS Firewall on Steroids&lt;/a&gt;: Something I want to do in the future.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hopefully you find one, or all of these a good, worthwhile read.&lt;/p&gt;</content><author><name>Stewart Polley</name></author><category term="What I'm reading" /><summary type="html">Welcome to the first monthly edition of my “What I’m reading” series. Click here to read other posts in this series.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="/wp-content/uploads/2018/01/what-im-reading-1125x675.jpeg" /><media:content medium="image" url="/wp-content/uploads/2018/01/what-im-reading-1125x675.jpeg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Django: Setting Cookie and returning a rendered template – an example</title><link href="/2018/01/13/django-setting-cookie-and-returning-a-rendered-template-an-example/" rel="alternate" type="text/html" title="Django: Setting Cookie and returning a rendered template – an example" /><published>2018-01-13T08:27:00+00:00</published><updated>2018-01-13T08:27:00+00:00</updated><id>/2018/01/13/django-setting-cookie-and-returning-a-rendered-template-an-example</id><content type="html" xml:base="/2018/01/13/django-setting-cookie-and-returning-a-rendered-template-an-example/">&lt;p&gt;While trying to figure out how to set cookies with Django (something I’ve been lucky enough to not have to do) I was of course searching “How to set a cookie with Django” &lt;a href=&quot;https://stackoverflow.com/questions/1622793/django-cookies-how-can-i-set-them&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;this&lt;/a&gt; was the first result I found. Now that’s a great link and all, and it points to the &lt;a href=&quot;https://docs.djangoproject.com/en/dev/ref/request-response/&quot;&gt;relevant Django Docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;However, there was a particular example missing. Returning a rendered template, with a cookie. Fortunately, it didn’t take long to figure it out, but I felt the fact that an exact example of this was missing as a little annoying. So for anyone else wondering “How do I return a rendered template AND set a cookie” here’s an example.&lt;/p&gt;

&lt;pre&gt;from django.shortcuts import render

def my_view(request):
    response = render(request, 'index.html')
    response.set_cookie('my_cookie', 'Here is my cookie!')
    return response&lt;/pre&gt;

&lt;p&gt;With any luck this will help at least one other person out there!&lt;/p&gt;

&lt;p&gt;Of course, please read up the &lt;a href=&quot;https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpResponse.set_cookie&quot;&gt;set_cookie&lt;/a&gt; and &lt;a href=&quot;https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpResponse.set_signed_cookie&quot;&gt;set_signed_cookie&lt;/a&gt; docs for more info on what you can do here.&lt;/p&gt;</content><author><name>Stewart Polley</name></author><category term="Django" /><category term="Python" /><summary type="html">While trying to figure out how to set cookies with Django (something I’ve been lucky enough to not have to do) I was of course searching “How to set a cookie with Django” this was the first result I found. Now that’s a great link and all, and it points to the relevant Django Docs.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="/wp-content/uploads/2018/01/cookies-219x146.jpeg" /><media:content medium="image" url="/wp-content/uploads/2018/01/cookies-219x146.jpeg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Introducing StewPolley Tools</title><link href="/2018/01/06/introducing-stewpolley-tools/" rel="alternate" type="text/html" title="Introducing StewPolley Tools" /><published>2018-01-06T06:23:07+00:00</published><updated>2018-01-06T06:23:07+00:00</updated><id>/2018/01/06/introducing-stewpolley-tools</id><content type="html" xml:base="/2018/01/06/introducing-stewpolley-tools/">&lt;p&gt;As mentioned in my “&lt;a href=&quot;http://stewpolley.local/2018/01/02/2017-year-in-review/&quot;&gt;year in review&lt;/a&gt;” post, I mentioned wanting to release tools that others may find useful in their day to day lives.&lt;/p&gt;

&lt;p&gt;I am glad to say that today marks the start of that, with &lt;a href=&quot;https://tools.stewpolley.com&quot;&gt;https://tools.stewpolley.com/&lt;/a&gt; going live today. My first tool I’m calling “Timezone Aligner” – It’s the same as many other tools out there, I can hardly take credit for an original design. The other tools out there didn’t suit my needs though. Living in Queensland (AEST), we don’t have Daylight savings. Many of the other Timezone converters out there don’t take this into account, and when you try to convert Australian Eastern Standard Time to Central Standard Time, if the other Australian states are observing Daylight savings, you simply couldn’t get these other tools to work.&lt;/p&gt;

&lt;p&gt;This tool takes this into account, and I like to think it’s a nice clean interface. I’m not a front end designer though, so feel free to tell me I’m wrong about that!&lt;/p&gt;

&lt;p&gt;You can access my &lt;a href=&quot;https://tools.stewpolley.com/timezones/&quot;&gt;Timezone Aligner here&lt;/a&gt;.&lt;/p&gt;</content><author><name>Stewart Polley</name></author><category term="Django" /><category term="Personal Updates" /><category term="Vue" /><summary type="html">As mentioned in my “year in review” post, I mentioned wanting to release tools that others may find useful in their day to day lives.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="/wp-content/uploads/2018/01/tools-219x146.jpeg" /><media:content medium="image" url="/wp-content/uploads/2018/01/tools-219x146.jpeg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Allowing HTML Purifier to accept the details and summary tags.</title><link href="/2018/01/05/allowing-html-purifier-to-accept-the-details-and-summary-tags/" rel="alternate" type="text/html" title="Allowing HTML Purifier to accept the details and summary tags." /><published>2018-01-05T07:48:09+00:00</published><updated>2018-01-05T07:48:09+00:00</updated><id>/2018/01/05/allowing-html-purifier-to-accept-the-details-and-summary-tags</id><content type="html" xml:base="/2018/01/05/allowing-html-purifier-to-accept-the-details-and-summary-tags/">&lt;p&gt;The &lt;a href=&quot;http://htmlpurifier.org/&quot;&gt;HTML Purifier library&lt;/a&gt; is a great way to filter user-supplied HTML, normally from WYSIWYG Rich Text editors, and remove potentially malicious content. It can also be used to ensure that certain elements &lt;em&gt;always&lt;/em&gt; get saved with particular attribues. Ie, ensuring any user-supplied link has &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;target=&quot;_blank&quot;&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rel=&quot;nofollow&quot;&lt;/code&gt;. Depending on your use case, you may even want to prevent users from inserting non HTTPS links etc.&lt;/p&gt;

&lt;p&gt;One downside to using a library for this, is if you want to use a newer HTML elements, such as &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details&quot;&gt;details&lt;/a&gt; and &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary&quot;&gt;summary&lt;/a&gt;, the library may not yet know about them! This is currently the case with HTML Purifier and these tags. &lt;a href=&quot;https://caniuse.com/#feat=details&quot;&gt;Most browsers support the&lt;/a&gt;, with IE and Edge being the main exceptions.&lt;/p&gt;

&lt;p&gt;These tags allow a really simple pure HTML only way of having an expandable section on your page. &lt;a href=&quot;https://codepen.io/anon/pen/aELqbP&quot;&gt;Here’s an example&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now that we know what these tags elements are, let’s look at how to implement them in HTML Purifier.&lt;/p&gt;

&lt;pre&gt;$config = \HTMLPurifier_Config::createDefault();
# Other configuration options you may use
$def = $config-&amp;gt;getHTMLDefinition(true);
$def-&amp;gt;addElement(
    'details',
    'Block',
    'Flow',
    'Common',
    array(
        'open' =&amp;gt; new \HTMLPurifier_AttrDef_HTML_Bool(true)
    )
);
$def-&amp;gt;addElement('summary', 'Inline', 'Inline', 'Common');&lt;/pre&gt;

&lt;p&gt;It’s not super-obvious when reading &lt;a href=&quot;http://htmlpurifier.org/docs/enduser-customize.html#addAttribute&quot;&gt;their docs&lt;/a&gt;, at least it wasn’t for myself, but you need to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;new \HTMLPurifier_AttrDef_HTML_Bool(true)&lt;/code&gt; for the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;'open'&lt;/code&gt; element. Simply using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;'open' =&amp;gt; 'Bool'&lt;/code&gt; doesn’t work, neither does &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;'open' =&amp;gt; new \HTMLPurifier_AttrDef_HTML_Bool()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Hopefully this will make it easier for someone else out there to add these super-cool elements into their list of allowed elements.&lt;/p&gt;</content><author><name>Stewart Polley</name></author><category term="PHP" /><category term="php" /><summary type="html">The HTML Purifier library is a great way to filter user-supplied HTML, normally from WYSIWYG Rich Text editors, and remove potentially malicious content. It can also be used to ensure that certain elements always get saved with particular attribues. Ie, ensuring any user-supplied link has target=&quot;_blank&quot; and rel=&quot;nofollow&quot;. Depending on your use case, you may even want to prevent users from inserting non HTTPS links etc.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="/wp-content/uploads/2018/01/800px-PHP-logo.svg-260x140.png" /><media:content medium="image" url="/wp-content/uploads/2018/01/800px-PHP-logo.svg-260x140.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">2017 Year in Review – What I’m reading!</title><link href="/2018/01/02/2017-year-in-review/" rel="alternate" type="text/html" title="2017 Year in Review – What I’m reading!" /><published>2018-01-02T10:57:44+00:00</published><updated>2018-01-02T10:57:44+00:00</updated><id>/2018/01/02/2017-year-in-review</id><content type="html" xml:base="/2018/01/02/2017-year-in-review/">&lt;p&gt;It’s a brand new year. Many people have set their new years resolutions, companies are starting new projects, and for those in Australia and other countries where school years match calendar years, school kids are getting ready to start another year at school. In many ways, this blog is one such “new thing” that’s being started.&lt;/p&gt;

&lt;p&gt;A common theme at the end of a year, is for a person or organisation to review the previous year, to highlight some special things they found and to look at what they’re wanting to do in the future. Unfortunately for me, I can’t do that this year as I’ve only just started documenting these things in a nice manner. However, I can still talk about things I want to do in the year to come!&lt;/p&gt;

&lt;h2 id=&quot;year-to-come&quot;&gt;Year to come&lt;/h2&gt;

&lt;p&gt;For 2018, there are three main things I’d like to do with this site.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Publish more consistently&lt;/li&gt;
  &lt;li&gt;Releasing guides and manuals&lt;/li&gt;
  &lt;li&gt;Give regular “What I’m reading” posts&lt;/li&gt;
  &lt;li&gt;Release tools online&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;publish-more-consistently&quot;&gt;Publish more consistently&lt;/h3&gt;

&lt;p&gt;If I get the other three done, this will be pretty easy. Basically though, I’ve ran other blogs in the past and I find that &lt;em&gt;starting&lt;/em&gt; a blog is easy. &lt;em&gt;Maintaining&lt;/em&gt; a blog is the hard part! If I can at the very least do weekly posts, I’ll be very satisfied with myself. If I manage monthly though, I’ll still be happy.&lt;/p&gt;

&lt;h3 id=&quot;releasing-guides-and-manuals&quot;&gt;Releasing guides and manuals&lt;/h3&gt;

&lt;p&gt;In a way, I feel my recent posts on &lt;a href=&quot;http://stewpolley.local/2017/12/16/rendering-a-json-string-inside-a-script-with-django/&quot;&gt;Rendering JSON Strings&lt;/a&gt; and &lt;a href=&quot;http://stewpolley.local/2017/11/21/django-axios-and-csrf/&quot;&gt;Django/Axios/CSRF&lt;/a&gt; were kind of a lead up to this, but I’m wanting to do more in-depth guides for people to use in the future. I’ve found other people’s guides out there super-useful, but I often find that I have to take some aspects from multiple guides and combine them together to get exactly the information I need. I plan on finding a scenario that I’m currently working on tackling, and writing guides that look at the issue and how I’ve solved them. I have one in the works already, hopefully &lt;em&gt;someone&lt;/em&gt; will find that useful!&lt;/p&gt;

&lt;h3 id=&quot;what-im-reading&quot;&gt;What I’m reading&lt;/h3&gt;

&lt;p&gt;This isn’t something I see very often in tech related blogs, but I’ve found these to be interesting posts in other fields before. Basically, I’ll keep a list of articles I find useful, and at the end of the month publish that list so that other people can see what I’ve been finding useful. Hopefully this helps other people find out about other bloggers that they may not have heard of before, and may find an article they otherwise would have missed. I’ve started this with a &lt;a href=&quot;http://stewpolley.local/recommended-reading/&quot;&gt;“Recommended reading”&lt;/a&gt; page that lists other bloggers, but these posts will be linking to &lt;em&gt;specific&lt;/em&gt; articles/posts, not just their main webpage.&lt;/p&gt;

&lt;h3 id=&quot;release-tools-online&quot;&gt;Release tools online&lt;/h3&gt;

&lt;p&gt;We all have various websites that have useful tools that we go to in our day-to-day work, without which we’d have a harder time getting our jobs done. Two such tools I find super-useful are &lt;a href=&quot;https://www.whatsmydns.net/&quot;&gt;whatsmydns&lt;/a&gt; and &lt;a href=&quot;https://www.whatsmybrowser.org/&quot;&gt;whatsmybrowser&lt;/a&gt;. I’ve got some tools that I’ve personally been using, that I’d like to share publicly as I feel others would also find them useful. Developing these tools also serves as a great learning experience for me too!&lt;/p&gt;

&lt;h2 id=&quot;2017-recommended-reading--year-in-review&quot;&gt;2017 Recommended Reading – Year in review&lt;/h2&gt;

&lt;p&gt;Now that I’ve said what I want to do more of in the year to come, let’s start off number 3 in that list and do my first “What I’m reading” post and do something similar to a “Year in review” post at the same time?&lt;/p&gt;

&lt;p&gt;Below are some articles that were published in 2017 that I found worth sharing.&lt;/p&gt;

&lt;h3 id=&quot;troy-hunt&quot;&gt;Troy Hunt&lt;/h3&gt;

&lt;p&gt;I find it interesting that I’ve been following Troy for close to two years now. Boy how time flies…&lt;/p&gt;

&lt;p&gt;Firstly, this series on Fixing Data Breaches by Troy Hunt was an interesting read, looking at ways that organisations can help minimise the damage when a data breach has occurred, ways of preventing them and how to encourage companies to do the right thing. This post may not be the most useful for individuals, but definitely worth the read if you’re a decision maker in a company. For ease of use, here’s the link to each individual part.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.troyhunt.com/fixing-data-breaches-part-1-education/&quot;&gt;Education&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.troyhunt.com/fixing-data-breaches-part-2-data-ownership-minimisation/&quot;&gt;Data Ownership &amp;amp; Minimsation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.troyhunt.com/fixing-data-breaches-part-3-the-ease-of-disclosure/&quot;&gt;Ease of Disclosure&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.troyhunt.com/fixing-data-breaches-part-4-bug-bounties/&quot;&gt;Bug Bounties&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.troyhunt.com/fixing-data-breaches-part-5-penalties/&quot;&gt;Penalties&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Following from this, albeit not chronologically, &lt;a href=&quot;https://www.troyhunt.com/data-breach-disclosure-101-how-to-succeed-after-youve-failed/&quot;&gt;was a post Troy&lt;/a&gt; made several months earlier on how an organisation should/shouldn’t act after a data breach has occurred.&lt;/p&gt;

&lt;p&gt;Other articles I’d include in a “Highlights of Troy Hunt for 2017” mix tape:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.troyhunt.com/the-6-step-happy-path-to-https/&quot;&gt;6 Step Happy Path to HTTPS&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.troyhunt.com/the-one-valuable-thing-all-websites-have-reputation-and-why-its-attractive-to-phishers/&quot;&gt;The one valuable things all websites have, and why Phishers want it&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.troyhunt.com/the-trouble-with-politicians-sharing-passwords/&quot;&gt;The trouble with politicians sharing passwords&lt;/a&gt; (or anyone for that matter!)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;scott-helme&quot;&gt;Scott Helme&lt;/h3&gt;

&lt;p&gt;Scott I’ve only been following for a shorter period of time, so it made this list a bit easier to write. Also he doesn’t post as much as Troy so there’s less articles to pick from, but they’re all equally useful.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://scotthelme.co.uk/malware-hunting-with-csp/&quot;&gt;Malware Hunting with CSP&lt;/a&gt; – This one I found particularly interesting. In my day-job hunting bugs in our software, I’m always looking for more ways of getting more useful debugging information!&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://scotthelme.co.uk/are-ev-certificates-worth-the-paper-theyre-written-on/&quot;&gt;Are EV certificates worth the paper they’re written on?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://scotthelme.co.uk/sarahah/&quot;&gt;Sarahah&lt;/a&gt; – Particularly topical as a lot of my friends started using this around the time this article came out!&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://scotthelme.co.uk/lets-encrypt-with-dns-round-robin/&quot;&gt;Let’s Encrypt with DNS Round Robin&lt;/a&gt; – An interesting read on using Let’s Encrypt on load balanced servers&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://scotthelme.co.uk/nomx-the-worlds-most-secure-communications-protocol/&quot;&gt;nomx: The worlds most “secure” communications protocol&lt;/a&gt; followed by the comments on &lt;a href=&quot;https://news.ycombinator.com/item?id=14209874&quot;&gt;Hacker News&lt;/a&gt;, a &lt;a href=&quot;http://www.zdnet.com/article/why-you-should-not-trust-nomx-secure-email-service/&quot;&gt;ZDnet article on the topic&lt;/a&gt; and of course &lt;a href=&quot;https://www.reddit.com/r/netsec/comments/67q06b/nomx_the_worlds_most_secure_communications/&quot;&gt;the comments on r/netsec&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;others&quot;&gt;Others&lt;/h3&gt;

&lt;p&gt;I kept Troy’s and Scott’s in their own section, simply because they have so many. They’re not the only sites I read though! Other great articles to read:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://hackernoon.com/why-the-internet-must-be-regulated-9d65031e7491&quot;&gt;Why the internet must be regulated&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://paragonie.com/blog/2017/12/2018-guide-building-secure-php-software&quot;&gt;2018 guide to building secure PHP software&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://dev.to/paragonie/php-72-the-first-programming-language-to-add-modern-cryptography-to-its-standard-library&quot;&gt;PHP 7.2 – The first programming language to add modern cryptography to its standard library&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://hackernoon.com/ten-years-in-nobody-has-come-up-with-a-use-case-for-blockchain-ee98c180100&quot;&gt;10 years in, nobody has come up with a use for blockchain&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.michalspacek.com/this-is-how-you-respond-to-a-disclosure&quot;&gt;This is how you respond to a disclosure&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/danielmiessler/SecLists/pull/155&quot;&gt;Remove my password so hackers can’t hack me&lt;/a&gt; (I think the guy’s making a joke… I think…)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.mailsploit.com/index&quot;&gt;Mailsploit&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html&quot;&gt;Announcing the first SHA-1 collision&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://medium.freecodecamp.org/how-i-hacked-hundreds-of-companies-through-their-helpdesk-b7680ddc2d4c&quot;&gt;How I hacked hundreds of companies through their helpdesk&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s hoping 2018 has even more worthwhile reads than 2017 did!&lt;/p&gt;</content><author><name>Stewart Polley</name></author><category term="What I'm reading" /><summary type="html">It’s a brand new year. Many people have set their new years resolutions, companies are starting new projects, and for those in Australia and other countries where school years match calendar years, school kids are getting ready to start another year at school. In many ways, this blog is one such “new thing” that’s being started.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="/wp-content/uploads/2018/01/what-im-reading-219x146.jpeg" /><media:content medium="image" url="/wp-content/uploads/2018/01/what-im-reading-219x146.jpeg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Rendering a JSON string inside a script with Django</title><link href="/2017/12/16/rendering-a-json-string-inside-a-script-with-django/" rel="alternate" type="text/html" title="Rendering a JSON string inside a script with Django" /><published>2017-12-15T21:03:42+00:00</published><updated>2017-12-15T21:03:42+00:00</updated><id>/2017/12/16/rendering-a-json-string-inside-a-script-with-django</id><content type="html" xml:base="/2017/12/16/rendering-a-json-string-inside-a-script-with-django/">&lt;p&gt;Building a list of form submissions in Django last night was causing me some issues. This is likely a common issue for people and something most people know already, but I wasn’t able to find a nice answer online after my searching, so here’s my solution for others to benefit from.&lt;/p&gt;

&lt;p&gt;My scenario:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Build a list of submissions inside the view&lt;/li&gt;
  &lt;li&gt;Pass these into the template, so that Vue could render the details&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I could have made the decision to load the page first, then use Axios to get the list of submissions, but I decided aginst that for now.&lt;/p&gt;

&lt;p&gt;As such, I had my view setup along these lines:&lt;/p&gt;

&lt;pre&gt;from django.shortcuts import render
import json
from myapp.models import MyModel

def my_view(request):
    my_models = myModel.objects.all()
    model_list = []
    for model in my_models:
        new_model = {
            'id': model.id,
            'name': model.name,
            'picture': model.picture
        }
        model_list.append(new_model)

    context={
        'models': json.dumps(model_list)
    }

    return render(request, 'my_template.html')
&lt;/pre&gt;

&lt;p&gt;&lt;small&gt;(I would like to use &lt;code&gt;model_to_dict&lt;/code&gt; from django.forms.models here but UUIDs don’t work nicely in my scenario…)&lt;/small&gt;&lt;/p&gt;

&lt;p&gt;My Vue JS:&lt;/p&gt;

&lt;pre&gt;var models= new Vue(
    {
        el: '#models',
        delimiters: [&quot;[%&quot;, &quot;%]&quot;],
        data: {
            models: model_list
        }
    }
);
&lt;/pre&gt;

&lt;p&gt;End of course, the template:&lt;/p&gt;

&lt;pre&gt;

&lt;/pre&gt;

&lt;p&gt;The problem here was though, Django was escaping the JSON string automatically. After doing some googling I found many solutions that said to use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;escapejs&lt;/code&gt; flag in conjunction with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;JSON.parse()&lt;/code&gt; but I wasn’t satisfied with that.&lt;/p&gt;

&lt;p&gt;Django has a tag for disabling the auto-escaping it does though. This allows you to do the following:&lt;/p&gt;

&lt;pre&gt;&amp;lt;script&amp;gt;

&amp;lt;/script&amp;gt;
&lt;/pre&gt;

&lt;p&gt;And voila! Django renders the JSON String in such a way that Javascript can work with it right away, without having to use JSON.parse on it.&lt;/p&gt;</content><author><name>Stewart Polley</name></author><category term="Django" /><category term="Javascript" /><category term="Old" /><category term="Python" /><category term="Vue" /><summary type="html">Building a list of form submissions in Django last night was causing me some issues. This is likely a common issue for people and something most people know already, but I wasn’t able to find a nice answer online after my searching, so here’s my solution for others to benefit from.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="/wp-content/uploads/2017/12/opengraph-icon-200x200-146x146.png" /><media:content medium="image" url="/wp-content/uploads/2017/12/opengraph-icon-200x200-146x146.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Django, Axios and CSRF</title><link href="/2017/11/21/django-axios-and-csrf/" rel="alternate" type="text/html" title="Django, Axios and CSRF" /><published>2017-11-20T21:05:19+00:00</published><updated>2017-11-20T21:05:19+00:00</updated><id>/2017/11/21/django-axios-and-csrf</id><content type="html" xml:base="/2017/11/21/django-axios-and-csrf/">&lt;p&gt;I am currently building a simple Django based web-app. Part of this app is a registration form. It has a rather nice UI, built from Vue, and I’m POSTing the data back to Django using Axios.&lt;/p&gt;

&lt;p&gt;One great thing about Django is it’s built-in CSRF protection. While I’m not an expert and can’t say it’s the best CSRF protection, at the very least it’s nice that it has &lt;em&gt;something&lt;/em&gt; built in.&lt;/p&gt;

&lt;p&gt;When posting via Axios though, you need to send through the CSRF token, somehow. Everyone was saying you had to post it back, but it took me a while to figure out &lt;em&gt;where&lt;/em&gt; you should be placing it. Eventually I found this snippet from the &lt;a href=&quot;https://docs.djangoproject.com/en/2.0/ref/csrf/#acquiring-the-token-if-csrf-use-sessions-is-false&quot;&gt;official Django Docs&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The CSRF header name is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HTTP_X_CSRFTOKEN&lt;/code&gt; by default, but you can customize it using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CSRF_HEADER_NAME&lt;/code&gt; setting.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This answered my questions, and I ended up with this little bit of JS inside my Vue method.&lt;/p&gt;

&lt;pre&gt;submit: function() {
    data: {...}; // The exact data doesn't matter
    csrftoken = Cookies.get('csrftoken'); // Using &lt;a href=&quot;https://github.com/js-cookie/js-cookie/&quot;&gt;JS Cookies library&lt;/a&gt;
    headers = {X_CSRFTOKEN: csrftoken};
    axios.post(url,data,{headers: headers});
}&lt;/pre&gt;

&lt;p&gt;Now of course I had a .then and .catch section after axios’ .post, but that should at least give you some idea of how you can do it.&lt;/p&gt;

&lt;h3 id=&quot;update&quot;&gt;Update:&lt;/h3&gt;

&lt;p&gt;After reviewing this and how Django works, I’ve made a quick change to this document. Django adds “HTTP_” to all header names, and converts all dashes to underscores. So if your client sends a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;'X-XSRF-TOKEN'&lt;/code&gt; header, the setting should be &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;'HTTP_X_XSRF_TOKEN'.&lt;/code&gt; In order to make use of the default setting, you need to send through X_CSRFTOKEN or X-CSRFTOKEN as the header name. If you use X-CSRFTOKEN you need to wrap it in ‘ in the JS code. IE:&lt;/p&gt;

&lt;pre&gt;headers = {'X-CSRFTOKEN': csrftoken};&lt;/pre&gt;

&lt;p&gt;Now you can avoid traps that I fell into.&lt;/p&gt;</content><author><name>Stewart Polley</name></author><category term="Django" /><category term="Old" /><category term="Python" /><summary type="html">I am currently building a simple Django based web-app. Part of this app is a registration form. It has a rather nice UI, built from Vue, and I’m POSTing the data back to Django using Axios.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="/wp-content/uploads/2017/12/opengraph-icon-200x200-146x146.png" /><media:content medium="image" url="/wp-content/uploads/2017/12/opengraph-icon-200x200-146x146.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Getting setup.py to add commands to the path</title><link href="/2017/01/10/getting-setup-py-to-add-commands-to-the-path/" rel="alternate" type="text/html" title="Getting setup.py to add commands to the path" /><published>2017-01-09T21:00:37+00:00</published><updated>2017-01-09T21:00:37+00:00</updated><id>/2017/01/10/getting-setup-py-to-add-commands-to-the-path</id><content type="html" xml:base="/2017/01/10/getting-setup-py-to-add-commands-to-the-path/">&lt;p&gt;There’s a number of articles out there that mention this, but they’re a bit of a pain to follow. Of them all, I found &lt;a href=&quot;http://python-packaging.readthedocs.io/en/latest/command-line-scripts.html&quot;&gt;this set of docs&lt;/a&gt; to be the most useful, but still lacking.&lt;/p&gt;

&lt;p&gt;This may, or may not, have been the case if I had read the entire docs, but that’s ok. This blog post is mainly designed just as a reference, for people who want to get their answers quickly, as I did, and without trial and error!&lt;/p&gt;

&lt;p&gt;For those that want a quick answer, when you’re using &lt;em&gt;setuptools&lt;/em&gt; in your setup function, you want to make use the of the &lt;em&gt;entry_points&lt;/em&gt; keyword.&lt;/p&gt;

&lt;p&gt;From the example above:&lt;/p&gt;

&lt;pre&gt;setup(
    ...
    entry_points = {
        'console_scripts': ['funniest-joke=funniest.command_line:main'],
    }
    ...
)&lt;/pre&gt;

&lt;p&gt;As a quick explanation of how this works:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;funniest-joke&lt;/em&gt; – This is the command that you’ll enter into your terminal window&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;funniest.command_line:main&lt;/em&gt; – This tells setuptools which file, and which function to call. In this example, it will go into the &lt;em&gt;funniest&lt;/em&gt; module, load the &lt;em&gt;command_line&lt;/em&gt; file, and execute the &lt;em&gt;main&lt;/em&gt; function&lt;/li&gt;
&lt;/ul&gt;</content><author><name>Stewart Polley</name></author><category term="Old" /><category term="Python" /><summary type="html">There’s a number of articles out there that mention this, but they’re a bit of a pain to follow. Of them all, I found this set of docs to be the most useful, but still lacking.</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="/wp-content/uploads/2017/12/opengraph-icon-200x200-146x146.png" /><media:content medium="image" url="/wp-content/uploads/2017/12/opengraph-icon-200x200-146x146.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Deleting files within a directory with a given extension</title><link href="/2015/07/05/deleting-files-within-a-directory-with-a-given-extension/" rel="alternate" type="text/html" title="Deleting files within a directory with a given extension" /><published>2015-07-04T20:13:12+00:00</published><updated>2015-07-04T20:13:12+00:00</updated><id>/2015/07/05/deleting-files-within-a-directory-with-a-given-extension</id><content type="html" xml:base="/2015/07/05/deleting-files-within-a-directory-with-a-given-extension/">&lt;p&gt;I wanted to delete a large number of .SRT files from some TV shows I had. (Sub-title files)&lt;/p&gt;

&lt;p&gt;Going through each folder + selecting the files individually is tedious.&lt;/p&gt;

&lt;p&gt;I wrote this bit of code, with the help of this Stack Overflow question.&lt;/p&gt;

&lt;p&gt;Save this to the directory you want to delete the files from.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python remove_srt.py extension1 extension2&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For example, to remove all JPG, TXT and PNG files:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python remove_srt.py jpg txt png&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Script is here:&lt;/p&gt;

&lt;pre&gt;import sys
import os

num_deleted = 0
num_skipped = 0

def scandirs(path, extensions):
    global num_deleted
    global num_skipped
    for root, dirs, files in os.walk(path):
        for currentFile in files:
            print(&quot;processing file: &quot; + currentFile)
            if any(currentFile.lower().endswith(ext) for ext in extensions):
                os.remove(os.path.join(root, currentFile))
                print(&quot;{} deleted&quot;.format(os.path.join(root, currentFile)))
                num_deleted += 1
            else:
                num_skipped += 1


if __name__ == '__main__':
    extensions = []
    for arg in sys.argv[1:]:
        
        extensions.append(arg)
    path = os.getcwd()
    scandirs(path, extensions)
    print(&quot;{} files deleted&quot;.format(num_deleted))
    print(&quot;{} files skipped&quot;.format(num_skipped))
&lt;/pre&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;dec-2017-update&quot;&gt;Dec 2017 update&lt;/h3&gt;

&lt;p&gt;Oh boy, how time flies and how we learn. I’ll get a post up in early 2018 with a better way of doing this.&lt;/p&gt;</content><author><name>Stewart Polley</name></author><category term="Old" /><category term="Python" /><summary type="html">I wanted to delete a large number of .SRT files from some TV shows I had. (Sub-title files)</summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="/wp-content/uploads/2017/12/opengraph-icon-200x200-146x146.png" /><media:content medium="image" url="/wp-content/uploads/2017/12/opengraph-icon-200x200-146x146.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>