Skip to content

Commit

Permalink
chore: Fixup docs
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Lilley Brinker <[email protected]>
  • Loading branch information
alilleybrinker committed Nov 8, 2024
1 parent 569b6ac commit 9b8675d
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 50 deletions.
6 changes: 2 additions & 4 deletions plugins/activity/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ impl Plugin for ActivityPlugin {
log::error!("tried to access config before set by Hipcheck core!");
return Err(Error::UnspecifiedQueryState);
};
match conf.weeks {
Some(weeks) => Ok(format!("lte $ P{}w", weeks)),
None => Ok("".to_owned()),
}

Ok(format!("lte $ P{}w", conf.weeks.unwrap_or(71)))
}

fn explain_default_query(&self) -> Result<Option<String>> {
Expand Down
1 change: 1 addition & 0 deletions plugins/affiliation/test/example_orgs.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ strategy "independent" {
country "United States"
org "MITRE"
}

orgs {
org "AT&T" country="United States" {
host "att.com"
Expand Down
7 changes: 1 addition & 6 deletions plugins/binary/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ mod error;
mod fs;

use crate::binary_detector::{detect_binary_files, BinaryFileDetector};

use clap::Parser;
use hipcheck_sdk::{prelude::*, types::Target};
use pathbuf::pathbuf;
use serde::Deserialize;

use std::{path::PathBuf, result::Result as StdResult, sync::OnceLock};

pub static DETECTOR: OnceLock<BinaryFileDetector> = OnceLock::new();
Expand Down Expand Up @@ -100,10 +98,7 @@ impl Plugin for BinaryPlugin {
fn default_policy_expr(&self) -> Result<String> {
match self.policy_conf.get() {
None => Err(Error::UnspecifiedQueryState),
// If no policy vars, we have no default expr
Some(None) => Ok("".to_owned()),
// Use policy config vars to construct a default expr
Some(Some(policy_conf)) => Ok(format!("(lte (count $) {})", policy_conf)),
Some(policy_conf) => Ok(format!("(lte (count $) {})", policy_conf.unwrap_or(0))),
}
}

Expand Down
29 changes: 9 additions & 20 deletions site/content/docs/guide/plugins/mitre-activity.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,21 @@ extra:

# `mitre/activity`

Activity analysis looks at the date of the most recent commit to the branch
pointed to by `HEAD` in the repository. In the case of a local repository
source, that may be a branch other than the default. In the case of a remote
repository, it will always be the default branch on the remote host.

Hipcheck identifies the committed date of the most recent commit, and
calculates the number of weeks between that commit and the day Hipcheck is
performing this analysis. It then compares that duration against the
configured threshold (default configuration: 71 weeks / one year). If the
duration in the repository is greater than the configured threshold, then
the analysis will be marked as a failure.

## Queries

### `mitre/activity` (default query)

Returns a `Span` representing the time from the most recent commit to now.
Determines if a project is actively maintained.

## Configuration

- `weeks`: An `Integer` of the permitted number of weeks before a project is
considered inactive.
| Parameter | Type | Explanation |
|:----------|:----------|:--------------|
| `weeks` | `Integer` | The permitted number of weeks before a project is considered inactive. |

## Default Policy Expression

`lte $ P{config.weeks}w`
`lte $ P{config.weeks or 71}w`

## Default Query: `mitre/activity`

Returns a `Span` representing the time from the most recent commit to now.

## Limitations

Expand Down
35 changes: 19 additions & 16 deletions site/content/docs/guide/plugins/mitre-affiliation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ extra:

# `mitre/affiliation`

Identifies project contributors affiliated with an organization of concern.

## Configuration

| Parameter | Type | Explanation |
|:------------------|:----------|:--------------|
| `orgs-file-path` | `String` | Path to an "orgs file" specifying how to match affiliation. |
| `count-threshold` | `Integer` | The permitted number of concerning contributors. |

## Default Policy Expression

`lte $ {config.count_threshold}`

## Default Query: `mitre/affiliation`

Returns the number of commits flagged for having concerning contributors.

## Explanation

Affiliation analysis tries to identify when commit authors or committers
may be affiliated or unaffiliated with some list of organizations.
This determination is based on the email address associated with authors or
Expand Down Expand Up @@ -49,22 +68,6 @@ This strategy spec would flag any commits those authors or committers can be
identified as being affiliated with any American company listed in the file or
with MITRE specifically.

## Queries

### `mitre/affiliation` (default query)

Returns the number of commits flagged for having concerning contributors.

## Configuration

- `orgs_spec`: specifies the policy for matching contributors
- `count_threshold`: an `Integer` expressing the permitted number of concerning
contributors.

## Default Policy Expression

`lte $ {config.count_threshold}`

## Limitations

* __The orgs file is limited__: The current construction requires the manual
Expand Down
19 changes: 19 additions & 0 deletions site/content/docs/guide/plugins/mitre-binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@ extra:

# `mitre/binary`

Identifies likely binary files in a source repository.

## Configuration

| Parameter | Type | Explanation |
|:---------------|:----------|:--------------|
| `binary-file` | `String` | Path to a file specifying how to match binaries. |
| `opt-thresold` | `Integer` | The number of detect binaries to permit. |

## Default Policy Expression

`(lte (count $) {config.opt-threshold or 0})`

## Default Query: `mitre/binary`

Returns an array of paths to binary files.

## Explanation

Binary analysis searches through all of the files in the repository for binary
files (i.e. files not in readable text) that may contain code. There is a high
liklihood that these are deliberately malicious insertions. The precense of such
Expand Down
3 changes: 2 additions & 1 deletion site/content/docs/guide/plugins/mitre-git.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ extra:

# `mitre/git`

TODO
Provides access to Git commit history data. Does not define a default query
and can't be used as a top-level plugin in a policy file.
3 changes: 2 additions & 1 deletion site/content/docs/guide/plugins/mitre-github.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ extra:

# `mitre/github`

TODO
Provides access to GitHub data. Does not define a default query and can't be
used as a top-level plugin in a policy file.
3 changes: 2 additions & 1 deletion site/content/docs/guide/plugins/mitre-linguist.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ extra:

# `mitre/linguist`

TODO
Analyzes text files to identify their likely language. Does not provide a
default query and can't be used as a top-level plugin in a policy file.
3 changes: 2 additions & 1 deletion site/content/docs/guide/plugins/mitre-npm.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ extra:

# `mitre/npm`

TODO
Provides access to NPM data for a package. Does not provide a default query
and can't be used as a top-level plugin in a policy file.

0 comments on commit 9b8675d

Please sign in to comment.