Monday, March 08, 2021

Eroror 404 saving Elementor Html Widget - Solution

Hi,

So, I encountered a situation where trying to save a piece of HTML & JS using an HTML widget in Elementor was returning a 404 error, not only that but after retrying several times I got blocked from the site.

Making a long story short, it turned out that the hosting company was running some software called mod security or modsec for short, and my code was interpreted as an sql injection attack on the site I was trying to edit.

So how do you work around this? how do you debug this if you encounter a similar issue?

1) Ask your hosting service to have alook in their modsec logs and find your ip to see why you are being blocked - they will send you something that looks like this (I did change the red parts and some of the numbers/tokens for security reasons).

[Sun Mar 07 14:11:15.331211 2021] [:error] [pid 119***5:tid 472*****20384] [client 11.22.33.44:5555] [client 11.22.33.44] ModSecurity: Access denied with code 403 (phase 2). Pattern match "LONG BUT INCOMPLETE REGEXP ..." at ARGS:actions. [file "/etc/apache2/conf.d/modsec/modsec/11_asl_adv_rules.conf"] [line "117"] [id "331028"] [rev "13"] [msg "Atomicorp.com WAF Rules:  Unauthorized SQL access to database Detected."] [data "SOME PART OF YOU HTML CODE"] [tag "SQLi"] [hostname "YOURDOMAINNAMEHERE"] [uri "/path-to-wp-admin/admin-ajax.php"] [unique_id "YETc4k********M1I-Ru7wACBwk"], referer: https://YOURDOMAINNAMEHERE/path-to-wp-admin/post.php?post=POSTIDHERE&action=elementor


2) You can see the file and line number of the rule  that you have hit and its id and revision,
     [file "/etc/apache2/conf.d/modsec/modsec/11_asl_adv_rules.conf"] [line "117"] [id "331028"] [rev "13"]

since it seems that those rules are being commercially sold by Atomicorp.com I am not publishing the actual pattern of the rule, but I did ask the hosting service and they where kind enough to share the full  rule with me - from the rule I extracted the Regex that comes after ARGS:wptextbox1 " in the full text for the rule up untill the " \ 

3) I went to https://regex101.com/  and pasted the regular expression in the appropriate text box and the code that I was trying to add to the site as part of the HTML widget. (make sure to remove surrounding " of the regexp pattern.

4) On the right side you will be able to see the match information showing you exactly what parts of your code trigger the security rule. (clicking a match will take you to the appropriate place in the code).

5) knowing this will hopefully allow you to go and modify your code so as not to trigger this rule.

In my case it was a JavaScript variable that the rule did not like its suffix together with the fact that there was an opening parenthesis less that 100 characters after it....

Good luck and leave me a not if it helped or if you have any additional Q's on this.

Eyal




Thursday, June 06, 2019

Prusa MK3 live Z calibration tips

Hi All,
Well its now maybe the 3rd or 4th time for me trying to wrap my head around the process of Live Z calibration so I though I would write a few words to help me remember whats waht next time...

So,

The process it self is designed to help fine tune to position of the nozzle relative to the bed to get good adhesion. It is performed by rotating the know during printing.

When rotating the knob COUNTER CLOCKWISE you make the negative value that is being displayed MORE NEGATIVE and you move the nozzle CLOSER TO THE PRINT BED.

You will probably need to repeat the process several times until you get it right.

I don't remember in which YouTube video I saw this so if you find it, leave a message in the comments, but it had the following tip:

While the lines pattern is being printed, move your finger gently perpendicular to the printed lines, when you are low enough the printed lines will not detach from the print bed.

It is also recommended that you make sure your print bed is clean before you do this as this also has a very significant influence on adhesion.

I hope this helps.

Monday, May 02, 2016

HP Officejet PRO 8500A A910 offline - Problem solved.

I am writing this post in hope that it will help some people.

The issue is that an HP Officejet PRO 8500A A910 shows as offline when you open the print queue dialog (in the caption it just says "HP Officejet PRO 8500A A910 - offline"), other then that I had network connectivity, ping, web interface was reachable and so on, It just would not print....

I have seen very long threads where people complain that their HP Officejet PRO 8500A A910 went offline and nothing helped.

They got many types of advice like switching from wireless to USB, changing IP and other network settings, disabling Power save mode , restart the printer or related router, use a different power cable and so on...

For me It turned out that the problem was that the cyan ink cartridge was just too old (two years and two months actually... - looks like I am not printing enough sea images...).

Changing the expired cartridge resolved the issue and the printer just came back online.

So how can you tell if that is the case with you ?

In the printer screen , press the ink icon (the one with the cyan, magenta, yellow & black circles on the top right).

You should see a yellow exclamation sign next to at least one of your ink cartridges.

Press the "More..." button and use the side arrows to brows through the cartridges.

If a cartridge is expired it will say so on the top line of the screen (above the ink level indicator).

Replace the expired cartridge and leave me a comment...

Eyal

1/1/2019: UPDATE (Another solution if the above is not the case for you):
[READ, BUT DONT DO THIS until you read the update below]
This was originally posted on Feb 5th 2106,
It is now Jan 1st 2019, and my printer went offline again....
I did remember that I have bloged about this in the past so I came back here,
only this time the cartridges seem o.k.
so I did some more reading and finnaly arrived at THIS LINK which had the sollution to my current "HP Officejet Pro 8500A Plus is offline" problem.

To sum up:
go to the printer properties, open the ports tab and press the configure port button.
then remove the check box from "SNMP Status Enabled".
printer should go online after you press "OK" and "Close".

I must add here the at first it did not wat to save my change and I deleted all the print jobs from the spooler and tried again and then it saved without a problem.

1/1/2019: UPDATE 2
well, I was too quick to go and blog about this,
although it did remove the offline notice on the printer,
the printer remained unavailable for printing,
digging further, it turned out that I did not have connectivity to my printer... (a cable got loose)
so, I now believe that what you should do if its not a cartridges issue is the following:
press the network icon on your printer, it should show the printer's IP address, try to ping it,
if it does not work... well, test all your cables...
personally I went beck to the SNMP checkbox and turned it back on...


Friday, October 09, 2015

OriginThinSetup.exe won't run (A solution)

So - my girl wanted to buy "The Sims 4" from EA.

so I headed to the EA site and after reading a bit about all the expansions etc purchased the basic game for her.

I was then told that I should go and download "Origin" which will have my game  in the "My Games" tab.

So I went to https://www.origin.com/en-ie/download and downloaded origin - a file named OriginThinSetup.exe was downloaded but just refused to do anything...

Tried to turn off my firewall & Anti Virus & Searching the net - nothing...

I was already on a phone call to EA Support waiting for someone to answer, when I decided to do a right-click, Properies on said file - My original intention was to see what was its exact size in case I will be asked, but then I saw at the bottom:






















I pressed the "Unblock" button and then executed the file successfully.

P.S. - You might also need to properly setup your firewall / AntiVirus & make sure you "Run As Administrator" but I am guesssing you already know about that...



Monday, September 07, 2015

Angular directives - what happens when - execution order of compile prelink and poslink

Hi,
A few days ago I stumbled upon the following to articles:


I think they are great and recommend that before you continue reading here you go and read them.

The reason I am writing this is because I think that although they are great they have a methodological problem that might leave with some wrong ideas on how things work.

The problem is that the example that Jurgen Van de Moere chose to use.

The DOM structure he used has a root node, a child node and a grandchild node.

This leads to some sort of a "serial" thinking about what is happening at the "nitty-gritty" level.

It is why he end up with statements like:

"After AngularJS travels down the DOM and has run all the compile functions, it traverses back up again and runs all associated post-link functions. 
The DOM is now traversed in the opposite direction and thus the post-link functions are called in reverse order. So while the reversed order looked strange a few minutes ago, it is now starting to make perfect sense."
and

"A pre-link function of an element is guaranteed to run before any pre-link or post-link function of any of its child elements."


Now lets choose to use a slightly different DOM that looks more like a real tree.
Say one that has a root with 2 children that each has 2 children of their own as in the following Plunker (derived from the original by Jurgen Van de Moere).

You will then see that the order of execution of the compile, pre-link and pos-link functions would be much better described like this:

Do a pre-order scan of the DOM tree, and run compile on each node you reach . Then, starting from the root, recursively scan  the DOM tree where on each node you run pre-link, then recursively process the child nodes and then run post link.

If you open the debugger on the above plunker, It will look like this:
2015-09-07 17:46:01.357 app.js:8 root: compile
2015-09-07 17:46:01.364 app.js:8 child1: compile
2015-09-07 17:46:01.364 app.js:8 grandchild1: compile
2015-09-07 17:46:01.365 app.js:8 grandchild2: compile
2015-09-07 17:46:01.365 app.js:8 child2: compile
2015-09-07 17:46:01.366 app.js:8 grandchild3: compile
2015-09-07 17:46:01.367 app.js:8 grandchild4: compile
2015-09-07 17:46:01.367 app.js:11 root: pre link
2015-09-07 17:46:01.368 app.js:11 child1: pre link
2015-09-07 17:46:01.368 app.js:11 grandchild1: pre link
2015-09-07 17:46:01.369 app.js:14 grandchild1: post link
2015-09-07 17:46:01.369 app.js:11 grandchild2: pre link
2015-09-07 17:46:01.370 app.js:14 grandchild2: post link
2015-09-07 17:46:01.370 app.js:14 child1: post link
2015-09-07 17:46:01.370 app.js:11 child2: pre link
2015-09-07 17:46:01.371 app.js:11 grandchild3: pre link
2015-09-07 17:46:01.371 app.js:14 grandchild3: post link
2015-09-07 17:46:01.372 app.js:11 grandchild4: pre link
2015-09-07 17:46:01.372 app.js:14 grandchild4: post link
2015-09-07 17:46:01.373 app.js:14 child2: post link
2015-09-07 17:46:01.373 app.js:14 root: post link

So to summarize what we have seen so far -
1. Compile parent before all children and before any linking.
2. Prelink any node before prelinking or postlinking any of its child nodes.
3. Postlink any node After prelinking AND POSTLINKING all its child nodes.

Note: Looking at the entire tree some nodes can be post-linked before some others get pre-linked.

but WAIT this does not end here,
because directives that use transclude:true must get their content as a compiled DOM on their own COMPILE we get the following:

Have a look at this plunker in which I changed the root and child 2 to be directives that use transclude
and we now get the following order:

2015-09-07 18:20:04.917 app.js:8 child1: compile
2015-09-07 18:20:04.917 app.js:8 grandchild1: compile
2015-09-07 18:20:04.918 app.js:8 grandchild2: compile
2015-09-07 18:20:04.919 app.js:8 grandchild3: compile
2015-09-07 18:20:04.919 app.js:8 grandchild4: compile
2015-09-07 18:20:04.920 app.js:29 Transcludingchild2: compile
2015-09-07 18:20:04.921 app.js:29 Transcludingroot: compile
2015-09-07 18:20:04.922 app.js:32 Transcludingroot: pre link
2015-09-07 18:20:04.923 app.js:11 child1: pre link
2015-09-07 18:20:04.923 app.js:11 grandchild1: pre link
2015-09-07 18:20:04.924 app.js:14 grandchild1: post link
2015-09-07 18:20:04.924 app.js:11 grandchild2: pre link
2015-09-07 18:20:04.925 app.js:14 grandchild2: post link
2015-09-07 18:20:04.925 app.js:14 child1: post link
2015-09-07 18:20:04.926 app.js:32 Transcludingchild2: pre link
2015-09-07 18:20:04.927 app.js:11 grandchild3: pre link
2015-09-07 18:20:04.927 app.js:14 grandchild3: post link
2015-09-07 18:20:04.928 app.js:11 grandchild4: pre link
2015-09-07 18:20:04.929 app.js:14 grandchild4: post link
2015-09-07 18:20:04.929 app.js:35 Transcludingchild2: post link
2015-09-07 18:20:04.930 app.js:35 Transcludingroot: post link

What do we see?
The root can not compile before its children so child1 and grandchild1 & grandchild2 get compiled, then it should be child2's turn but since he is transcluding now he can not be complied before grandchild3 and grandchild4 (maybe they should have been called grandchild21 and grandchild22...) and only when they are complied can child2 and then the root be finally complied.

In a sense we could think of pre-compile and and post-compile that are called on a node before it children are compiled and after it where the pre-complie is called on non transcluding directives and the pos-compile is called on the ones that ARE using transclusion.

that said we can see that the order of linking remains unaffected by the added transclusion.

Write and tell me what you think.







 
Clicky Web Analytics