This is a migrated thread and some comments may be shown as answers.

Check the validity of the FiddlerScript Rules file (CustomRules.js)

4 Answers 316 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Iron
Iron
Alex asked on 27 Nov 2019, 12:51 PM
Is there a way to have Fiddler not update the FiddlerScript rules file (CustomRules.js) in case the file contains any errors?

I use Fiddler to block some traffic, but in case the rules file contains even a small error, then Fiddler will drop all the rules inside the file and allow all traffic to pass.

The best solution would be to first check the validity of the file, and only update it in case it contains no error at all.

I woulnd't mind automating this through a Perl script, but I still need a way to interogate Fiddler over the validity of the file.

In case there is no easy way to do this, my only option would be to write a Perl script that will initiate a web connection that is supposed to be blocked by Fiddler. In case it is not blocked, I can only assume the rules file I had just updated right before initiating the connection contains an error. In this case, the Perl script would kill Fiddler, replace the rules file with the previous version, and restart Fiddler. Everything should not take more than just a few seconds. This way, even if the file is not valid, Fiddler will continue to apply the rules (and block the traffic I need to filter out). My only problem with this solution is that it will take me some time to code it. I am looking for a more elegant, quicker way to do it.

Thank you,

Alex

4 Answers, 1 is accepted

Sort by
0
Eric R | Senior Technical Support Engineer
Telerik team
answered on 02 Dec 2019, 04:23 PM

Hi Alex,

I am not entirely certain I understand the requirement because Fiddler checks for validity of the CustomRules.js file at Runtime and an error is produced after each save if it exists. There are other options that might also meet the needs which I have listed below. 

1. The FiddlerApplication.Log.LogFormat("Got HTTP/{0} for {1}", oSession.responseCode, oSession.url); could be used to output the results of a specific function.

2. An Extension could be built to do this.

3. The AutoResponder could be used instead.

I hope this helps. Please let me know if you need any additional information. Thank you for using the Fiddler Forums.

Regards,


Eric R | Technical Support Engineer
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Alex
Top achievements
Rank 1
Iron
Iron
answered on 02 Dec 2019, 06:26 PM
Dear Eric,

Thank you for your answer!

> I am not entirely certain I understand the requirement because Fiddler checks for validity
> of the CustomRules.js file at Runtime and an error is produced after each save if it exists.

Indeed, Fiddler does check the CustomRules.js validity after each save, but in case there is an error, it will stop applying the rules in the file. From that point on, it will run as if there is no rules file at all. At least, this is what happens in my case. Like I said, my CustomRules.js file contains various rules that block some certain Internet traffic, but when an update is made with an invalid rules file, I get the "FiddlerScript rules failed to load" message in the log, and then traffic is no longer filtered.

Your first suggestion could be helpful to me. Still, not by accessing the results of a specific function, but by accessing the log file itself. That is because the Perl script can check for the "FiddlerScript rules failed to load" message after each update that takes place. This would perfect, and very easy to implement.

I already searched the Internet for information about exporting the log messages to an external file, automatically and in real time. I found this instruction:

@Log.Export \"C:\\temp\\filename.rtf\"

I tried adding it to the CustomRules.js file, but I got this error: "Conditional compilation is turned off"

Can you please tell me if this instruction is indeed the one I need to use, and how can I make it work?

Thank you,

Alex
0
Eric R | Senior Technical Support Engineer
Telerik team
answered on 02 Dec 2019, 07:44 PM

Hi Alex,

The @Log.* are Log Macro Functions intended to be used with the QuickExec box. For example, to preform the command execute log "@Log.Export \"C:\\temp\\filename.rtf\"" in the QuickExec box. From my understanding, this may require creating a Custom Exporter as shown in the Build a Custom Importer and Exporter documentation or Automatically Export Fiddler Data thread. In this case, you would write the extension and use it from the CustomRules.js file. See the following references for more details on extending Fiddler.

- Configure Visual Studio

Implement Fiddler Interfaces

Importer and Exporter Interfaces

Create Fiddler Extension Project

 - Load Extension in Fiddler

Please let me know if you have any additional questions. Thank you.

Regards,


Eric R | Technical Support Engineer
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Alex
Top achievements
Rank 1
Iron
Iron
answered on 03 Dec 2019, 08:06 AM

All right, thank you once again!

 

Alex

Tags
Fiddler Classic
Asked by
Alex
Top achievements
Rank 1
Iron
Iron
Answers by
Eric R | Senior Technical Support Engineer
Telerik team
Alex
Top achievements
Rank 1
Iron
Iron
Share this question
or