Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated verify_policy tool #7142

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions java/arcs/tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,15 @@ into textprotos.
```
$ bazel run --run_under="cd $PWD && " //java/arcs/tools:inspect_manifest -- ./ok_check_multiple_or_tags.binarypb ./ok_check_multiple_or_tags.textproto
```

## verify_policy

Verifies that all recipes in an Arcs manifest file comply with their policies.

```
# bazel run //java/arcs/tools:verify_policy -- /absolute/path/to/binary_manifest.binarypb
```

Options:
- `-d, --debug`: Turn on debug tracing
- `--help`: Display usage info
17 changes: 13 additions & 4 deletions java/arcs/tools/VerifyPolicy.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,30 @@ import arcs.core.analysis.PolicyVerifier
import arcs.core.data.proto.ManifestProto
import arcs.core.data.proto.decodeRecipes
import arcs.core.policy.proto.decode
import arcs.core.util.Log
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.CliktError
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.required
import com.github.ajalt.clikt.parameters.types.file

class VerifyPolicy : CliktCommand(
name = "verify_policy",
help = "Verifies that all recipes in an Arcs manifest file comply with their policies."
help = "Verifies that all recipes in an Arcs manifest file comply with their policies.",
printHelpOnEmptyArgs = true
) {
val manifest by option(
val manifest by argument(
help = "Arcs manifest to check, encoded as a binary proto file (.binarypb)"
).file().required()
).file()

val debug by option("-d", "--debug", help = "Turn on debug tracing")
.flag(default = false)

override fun run() {
if (debug) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My pleasure!

Log.level = Log.Level.Debug
}
val manifestProto = ManifestProto.parseFrom(manifest.readBytes())

val recipes = manifestProto.decodeRecipes()
Expand Down