README 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. sepolicy-analyze
  2. A component-ized tool for performing various kinds of analysis on a
  3. sepolicy file. The current kinds of analysis that are currently
  4. supported include:
  5. TYPE EQUIVALENCE (typecmp)
  6. sepolicy-analyze out/target/product/<board>/root/sepolicy typecmp -e
  7. Display all type pairs that are "equivalent", i.e. they are
  8. identical with respect to allow rules, including indirect allow
  9. rules via attributes and default-enabled conditional rules
  10. (i.e. default boolean values yield a true conditional expression).
  11. Equivalent types are candidates for being coalesced into a single
  12. type. However, there may be legitimate reasons for them to remain
  13. separate, for example: - the types may differ in a respect not
  14. included in the current analysis, such as default-disabled
  15. conditional rules, audit-related rules (auditallow or dontaudit),
  16. default type transitions, or constraints (e.g. mls), or - the
  17. current policy may be overly permissive with respect to one or the
  18. other of the types and thus the correct action may be to tighten
  19. access to one or the other rather than coalescing them together,
  20. or - the domains that would in fact have different accesses to the
  21. types may not yet be defined or may be unconfined in the policy
  22. you are analyzing.
  23. TYPE DIFFERENCE (typecmp)
  24. sepolicy-analyze out/target/product/<board>/root/sepolicy typecmp -d
  25. Display type pairs that differ and the first difference found
  26. between the two types. This may be used in looking for similar
  27. types that are not equivalent but may be candidates for coalescing.
  28. DUPLICATE ALLOW RULES (dups)
  29. sepolicy-analyze out/target/product/<board>/root/sepolicy dups
  30. Displays duplicate allow rules, i.e. pairs of allow rules that
  31. grant the same permissions where one allow rule is written
  32. directly in terms of individual types and the other is written in
  33. terms of attributes associated with those same types. The rule
  34. with individual types is a candidate for removal. The rule with
  35. individual types may be directly represented in the source policy
  36. or may be a result of expansion of a type negation (e.g. domain
  37. -foo -bar is expanded to individual allow rules by the policy
  38. compiler). Domains with unconfineddomain will typically have such
  39. duplicate rules as a natural side effect and can be ignored.
  40. PERMISSIVE DOMAINS (permissive)
  41. sepolicy-analyze out/target/product/<board>/root/sepolicy permissive
  42. Displays domains in the policy that are permissive, i.e. avc
  43. denials are logged but not enforced for these domains. While
  44. permissive domains can be helpful during development, they
  45. should not be present in a final -user build.
  46. BOOLEANS (booleans)
  47. sepolicy-analyze out/target/product/<board>/root/sepolicy booleans
  48. Displays the boolean names in the policy (if any).
  49. Policy booleans are forbidden in Android policy, so if there is any
  50. output, the policy will fail CTS.
  51. ATTRIBUTE (attribute)
  52. sepolicy-analyze out/target/product/<board>/root/sepolicy attribute <name>
  53. Displays the types associated with the specified attribute name.
  54. sepolicy-analyze out/target/product/<board>/root/sepolicy attribute -r <name>
  55. Displays the attributes associated with the specified type name.
  56. sepolicy-analyze out/target/product/<board>/root/sepolicy attribute -l
  57. Displays all attributes in the policy.
  58. NEVERALLOW CHECKING (neverallow)
  59. sepolicy-analyze out/target/product/<board>/root/sepolicy neverallow \
  60. [-w] [-d] [-f neverallows.conf] | [-n "neverallow string"]
  61. Check whether the sepolicy file violates any of the neverallow rules
  62. from the neverallows.conf file or a given string, which contain neverallow
  63. statements in the same format as the SELinux policy.conf file, i.e. after
  64. m4 macro expansion of the rules from a .te file. You can use an entire
  65. policy.conf file as the neverallows.conf file and sepolicy-analyze will
  66. ignore everything except for the neverallows within it. You can also
  67. specify this as a command-line string argument, which could be useful for
  68. quickly checking an individual expanded rule or group of rules. If there are
  69. no violations, sepolicy-analyze will exit successfully with no output.
  70. Otherwise, sepolicy-analyze will report all violations and exit
  71. with a non-zero exit status.
  72. The -w or --warn option may be used to warn on any types, attributes,
  73. classes, or permissions from a neverallow rule that could not be resolved
  74. within the sepolicy file. This can be normal due to differences between
  75. the policy from which the neverallow rules were taken and the policy
  76. being checked. Such values are ignored for the purposes of neverallow
  77. checking.
  78. The -d or --debug option may be used to cause sepolicy-analyze to emit the
  79. neverallow rules as it parses them. This is principally a debugging facility
  80. for the parser but could also be used to extract neverallow rules from
  81. a full policy.conf file and output them in a more easily parsed format.