Force Google SafeSearch in DansGuardian

I have been trying to get DansGuardian (now called E2Guardian) to force everyone to go through Google SafeSearch when they are searching using any Google service (images, web search, code, whatever). DansGuardian, as of 2.9.0.1, includes the ability to run Regular Expressions on urls, body content, and headers.

Google allows you to force safesearch by adding the option safe=on or safe=active to the url. In addition, Google has an undocumented feature that allows you to set “VerySafeSearch” by adding the safe=vss option. What I am trying to do is use the regexp url function to add this option.

DansGuardian has an example included that should force VSS on image search. Sadly, it does not work. Here is what I came up with:

"safe=off"->""
"(^http://[a-z]*\.google\.[a-z]*/[a-z]*\?)"->"\1safe=vss&"

These two lines need to be put into the file /etc/dansguardian/lists/urlregexplist. This should force Google VSS on all Google search services (except youtube) in all country codes (e.g. google.uk, google.cn, google.ca).

There are two parts to this. The first line removes the option that disables safe search: safe=off. The second line adds the safe=vss option.

The basic replacement syntax is this:
""->""
Simply, what is found between the first set of quotes is replaced by what is found in the second. For more details about regular expressions and danguardian see the following sites:
Perl Regular Expressions
Regular Expressions in Perl
Regular Expressions in DansGuardian

If anyone finds a way to get around this, please comment.

7 Responses to “Force Google SafeSearch in DansGuardian”

  1. Anonymous

    Hi,

    The example supplied with Dansguardian forces image searches to be safe, and works fine for that. To force Google to use safe mode for normal searches try this:

    # … remove ‘safe=…’
    “(^http://[0-9a-z]+\.google\.[a-z]+[-/%.0-9a-z]*/search\?)(.*)(&?)(safe=[^&]*)”->”\1\2\3″
    # … and add ‘safe=vss’
    “(^http://[0-9a-z]+\.google\.[a-z]+[-/%.0-9a-z]*/search\?)”->”\1safe=vss&”

    This works fine for me …

    Steve.

    Reply
  2. Rob

    Seems to be a loophole if you go to google image search, type something risky with strict filtering on then search, then turn safesearch off and it will auto fill the page with results you wouldn’t have been able to see if you had hit search.

    Reply
  3. Terry

    To do something similar for youtube.

    Add this to bannedregexpheaderlist
    PREF=f3.*$
    PREF=f1=[0-9]*&f3.*$

    Adding this to exceptionregexpurllist will allow you to go to the youtube home page to turn safety mode on.
    youtube.com$
    youtube.com.*action_get_safetymode_picker.*$
    youtube.com/set_safety_mode.*$
    youtube.com/index\?.*$


    Terry

    Reply
  4. William Johnston

    I haven’t looked at any solutions for this. The posted solution is definitely broken, and so much of Google is AJAX these days, I am not sure if there is a good solution. I hope to take another look at this some day, perhaps this summer.

    Reply

Leave a Reply to Bob

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>