tis-config-firefox

68.2-3
Configuration for Mozilla Firefox - The package will not have any effect if an ADMX GPO for Firefox is applied
949 downloads
Download

  Description 

  • package : tis-config-firefox
  • version : 68.2-3
  • architecture : all
  • categories : System and network
  • maintainer : WAPT Team,Tranquil IT,Jimmy PELÉ
  • description : Configuration for Mozilla Firefox - The package will not have any effect if an ADMX GPO for Firefox is applied
  • locale :
  • target_os : windows
  • min_os_version :
  • max_os_version :
  • min_wapt_version : 1.8
  • sources : https://github.com/mozilla/policy-templates/
  • installed_size :
  • impacted_process :
  • description_fr :
  • description_pl :
  • description_de :
  • description_es :
  • description_pt :
  • description_it :
  • description_nl :
  • description_ru :
  • editor : Mozilla Foundation
  • licence : MPL-2.0
  • signature_date : 2020-10-23T17:39:20.241286
  • Homepage : https://support.mozilla.org/kb/customizing-firefox-using-policiesjson

  Setup.py 

# -*- coding: UTF-8 -*-
from setuphelpers import *
import json
import platform

uninstallkey = []

# Installation procedure: https://support.mozilla.org/kb/customizing-firefox-using-policiesjson
# https://klaus-hartnegg.de/gpo/2018-05-26-Firefox-Policies.html

# Defining variables
app_name ='Mozilla Firefox'
policies_file = 'policies.json'
#ext_dir = 'extensions'
policies_content = """ {
  "policies": {
    "Cookies": {
      "AcceptThirdParty": "never",
      "Default": true,
      "ExpireAtSessionEnd": true,
      "Locked": true,
      "RejectTracker": true
    },
    "DNSOverHTTPS": {
      "Enabled": false,
      "Locked": true
    },
    "DisableTelemetry": true,
    "DisableBuiltinPDFViewer": true,
    "DisableAppUpdate": true,
    "DisableFeedbackCommands": true,
    "DisableProfileRefresh": true,
    "DisableFirefoxAccounts": true,
    "DisableFirefoxScreenshots": true,
    "DisableFirefoxStudies": true,
    "DisablePocket": true,
    "DisplayBookmarksToolbar": true,
    "DontCheckDefaultBrowser": true,
    "OfferToSaveLogins": true,
    "UserMessaging": {
      "WhatsNew": false,
      "ExtensionRecommendations": false,
      "FeatureRecommendations": false,
      "UrlbarInterventions": false
    },
    "Certificates": {
      "ImportEnterpriseRoots": true
    },
    "SearchBar": "unified",
    "Preferences": {
      "security.enterprise_roots.enabled": true,
      "datareporting.policy.dataSubmissionPolicyBypassNotification": true
    },
    "DisableSecurityBypass": {
      "InvalidCertificate": false,
      "SafeBrowsing": false
    },
    "EnableTrackingProtection": {
      "Cryptomining": true,
      "Locked": true,
      "Value": true
    },
    "FlashPlugin": {
      "Default": false
    },
    "ExtensionUpdate": true,
    "ExtensionSettings": {
      "uBlock0@raymondhill.net": {
        "installation_mode": "force_installed",
        "install_url": "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi"
      }
    },
    "NewTabPage": false,
    "NoDefaultBookmarks": true,
    "Homepage": {
      "StartPage": "homepage"
    },
    "NetworkPrediction": false,
    "OverrideFirstRunPage": "",
    "OverridePostUpdatePage": "",
    "PopupBlocking": {
      "Default": true
    }
  }
} """


def install():
    # Installing the package
    for ffox in installed_softwares(name=app_name):
        # Initializing variables
        ffox_dir = ffox['install_location']
        ffox_dist_dir = makepath(ffox_dir,'distribution')
        policies_path = makepath(ffox_dist_dir,policies_file)

        # Writing Firefox configuration file
        if not isdir(ffox_dist_dir):
            mkdirs(ffox_dist_dir)
        print("Writing Firefox configuration file: %s" % policies_path)
        """ # Merging actual Firefox configuration file with defined one (may fail)
        if isfile(policies_path):
            old_data = json_load_file(policies_path)
            new_data = json.loads(policies_content)
            data = data_merge(old_data,new_data)
            json_write_file(policies_path, data, indent=2)
        else:
            data = json.loads(policies_content)
            json_write_file(policies_path, data, indent=2) """

        # Forcing package Firefox configuration
        if isfile(policies_path):
            remove_file(policies_path)
        json_write_file(policies_path,json.loads(policies_content) , sort_keys=True, indent=2)

    # Removing policies from registry since it bypass the policies.json file (source: https://support.mozilla.org/bm/questions/1236197)
    ffox_policies_reg_path = r'SOFTWARE\Policies\Mozilla\Firefox'
    if reg_key_exists(HKEY_LOCAL_MACHINE,ffox_policies_reg_path):
        registry_deletekey(HKEY_LOCAL_MACHINE,ffox_policies_reg_path,'',force=True)


def uninstall():
    # Uninstalling the package
    for ffox in installed_softwares(name=app_name):
        # Initializing variables
        ffox_dir = ffox['install_location']
        ffox_dist_dir = makepath(ffox_dir,'distribution')
        policies_path = makepath(ffox_dist_dir,policies_file)

        # Removing Firefox configuration
        if isfile(policies_path):
            remove_file(policies_path)


def audit():
    # Verifying that the configuration is applied
    for ffox in installed_softwares(name=app_name):
        # Initializing variables
        ffox_dir = ffox['install_location']
        ffox_dist_dir = makepath(ffox_dir,'distribution')
        policies_path = makepath(ffox_dist_dir,policies_file)
        if not isfile(policies_path):
            print("WARNING: Configuration is NOT applied for %s, Re-applying" % ffox['name'])
            install()
            #print("WARNING: Configuration is NOT applied for %s, you may have to force reinstall the package" % ffox['name'])
            return "WARNING"
        else:
            print("OK: Configuration is correctly applied for %s" % ffox['name'])
            return "OK"

    print("WARNING: Firefox is NOT installed")
    return "WARNING"


def update_package():
    # Initializing variables
    version = control.get_software_version()

    # Incrementing version of the package
    control.version = '%s-%s'%(version,int(control.version.split('-')[-1])+1)
    control.save_control_to_wapt()
    print('Changing package version to: %s in WAPT\\control' % control.version)




def json_load_file(json_file):
    with open(json_file) as read_file:
        return json.load(read_file)


def json_write_file(json_file, data, sort_keys=True, indent=4):
    if platform.python_version_tuple()[0] == '3':
        with open(json_file, 'w', encoding='utf-8') as write_file:
            json.dump(data, write_file, sort_keys=sort_keys, indent=indent)
    else:
        with open(json_file, 'w') as write_file:
            json.dump(data, write_file, sort_keys=sort_keys, indent=indent)


def data_merge(a, b):
    """merges b into a and return merged result

    NOTE: tuples and arbitrary objects are not handled as it is totally ambiguous what should happen"""
    key = None
    # ## debug output
    # sys.stderr.write("DEBUG: %s to %s\n" %(b,a))
    try:
        if a is None or isinstance(a, str) or isinstance(a, unicode) or isinstance(a, int) or isinstance(a, long) or isinstance(a, float):
            # border case for first run or if a is a primitive
            a = b
        elif isinstance(a, list):
            # lists can be only appended
            if isinstance(b, list):
                # merge lists
                a.extend(b)
            else:
                # append to list
                a.append(b)
        elif isinstance(a, dict):
            # dicts must be merged
            if isinstance(b, dict):
                for key in b:
                    if key in a:
                        a[key] = data_merge(a[key], b[key])
                    else:
                        a[key] = b[key]
    except TypeError as e:
        raise Exception('TypeError "%s" in key "%s" when merging "%s" into "%s"' % (e, key, b, a))
    return a


										

  Changelog 


No changelog
  manifest.sha256 
[["setup.py","4d52910e25a1632b0b8df23aea975183d8e3ef9fb7127b80cb11f05f7deb9ae0"],["WAPT/icon.png","0750ff4649741284d4b6140fbca1d53a7a3e41215d524181a139e761db490311"],["WAPT/certificate.crt","a5a97261381e1d0ad46ee15916abec9c2631d0201f5cc50ceb0197a165a0bbbf"],["WAPT/control","23f565f1aff8406c38b5a6247fe3e1acdd399eb42cbfc4063caac34c16c058ba"]]