def testRootPATHDirCheck(self):

    data = [
        # Bad cases:
        # Non-root group ownership & permissions.
        self.CreateStat("/usr/local/bin", 0, 60, 0o0040775),
        # File & Non-root owner.
        self.CreateStat("/bin", 70, 0, 0o0100660),
        # A non-root symlink.
        self.CreateStat("/usr/local/sbin", 1, 0, 0o0120777),
        # File not owned by root but has no write permissions.
        self.CreateStat("/sbin", 1, 0, 0o0100400),
        # Fully root owned dir, but world writable.
        self.CreateStat("/usr", 0, 0, 0o0040666),

        # Safe cases:
        self.CreateStat("/usr/local", 0, 0, 0o0040755),  # Root owned directory.
        self.CreateStat("/usr/bin", 0, 0, 0o0120777),  # Root owned symlink.
        self.CreateStat("/usr/sbin", 0, 0, 0o0100775)]  # Root owned file.

    results = self.GenResults(["RootEnvPathDirs"], [data])

    check_id = "CIS-ROOT-PATH-HAS-FOLDERS-WRITABLE-BY-NON-ROOT"
    sym = ("Found: Folders that comprise the default $PATH of root can be "
           "modified by non-privileged users.")
    found = ["/usr/local/bin user: 0, group: 60, mode: drwxrwxr-x",
             "/bin user: 70, group: 0, mode: -rw-rw----",
             "/usr/local/sbin user: 1, group: 0, mode: lrwxrwxrwx",
             "/sbin user: 1, group: 0, mode: -r--------",
             "/usr user: 0, group: 0, mode: drw-rw-rw-"]
    self.assertCheckDetectedAnom(check_id, results, sym, found)
Ensure root $PATH directory entries are editable only by root.
dataset/ETHPy150Open google/grr/grr/checks/stat_test.py/StatOnlyTests.testRootPATHDirCheck