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

Implement in_toto_run #7

Merged
merged 28 commits into from
Aug 12, 2021
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6b9cd30
:new: Add Skeleton for InTotoRun
joyliu-q Jun 29, 2021
d8de0e5
:new: Fill-in skeleton, add recordartifacts & runcommand
joyliu-q Jun 30, 2021
fd99f0a
:broom: Clean code, propagate errors
joyliu-q Jul 1, 2021
a6170a3
:shirt: Remove Unnecessary Return Statement
joyliu-q Jul 1, 2021
6a35d8b
:broom: Return status code, correct doc, cosmetics
joyliu-q Jul 2, 2021
2c01646
:heavy_check_mark: Make tests pass
joyliu-q Jul 2, 2021
27e12d3
:new: Add run_dir parameter, canonicalize path
joyliu-q Jul 2, 2021
cb93298
:zap: Better path handling & test_record_artifacts
joyliu-q Jul 4, 2021
6e0ddf5
:new: Add example usage for in_toto_run
joyliu-q Jul 4, 2021
fdfab27
:tada: Handle symbolic links & record_artifacts breakdown
joyliu-q Jul 6, 2021
eff788c
:new: Add hash_algorithms parameter
joyliu-q Jul 6, 2021
640b370
:heavy_check_mark: Add hash_algorithms to example
joyliu-q Jul 8, 2021
46d9a42
:tada: Add path normalization using path_clean
joyliu-q Jul 8, 2021
890372c
:new: Add Link Generation, Rename Metablock
joyliu-q Jul 11, 2021
228bc35
Merge branch 'master' of https://github.com/in-toto/in-toto-rs into a…
joyliu-q Jul 11, 2021
8e6fb7d
:books: Add to Documentation
joyliu-q Jul 12, 2021
99762ee
:bug: Add path-clean as dependency
joyliu-q Jul 19, 2021
2e83e00
:bug: Make Keys a Reference
joyliu-q Jul 19, 2021
402083d
:new: Add runlib tests & placeholders
joyliu-q Jul 26, 2021
714b8c1
:new: Clean-up & Add tests
joyliu-q Jul 30, 2021
2805e39
:bug: More contextual err handling in run_command
joyliu-q Aug 2, 2021
7eae8c9
:art: Add run_command check for empty slice passed
joyliu-q Aug 10, 2021
02d44c1
:new: Add back typ field to preserve type & name
joyliu-q Aug 11, 2021
6639884
:heavy_check_mark: Pass tests for absolute paths
joyliu-q Aug 11, 2021
59e2b14
:heavy_check_mark: Remove symdir
joyliu-q Aug 12, 2021
f8531f1
:bug: Address comments & make test pass on Github
joyliu-q Aug 12, 2021
26023c9
:broom: Delete symbolic link to file
joyliu-q Aug 12, 2021
f5e6479
:broom: Delete symbolic link to folder
joyliu-q Aug 12, 2021
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
10 changes: 8 additions & 2 deletions src/runlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ pub fn record_artifacts(
/// let byproducts = run_command(&["sh", "-c", "printf hello"], Some("tests")).unwrap();
/// ```
pub fn run_command(cmd_args: &[&str], run_dir: Option<&str>) -> Result<BTreeMap<String, String>> {
// Format output into Byproduct
let mut byproducts: BTreeMap<String, String> = BTreeMap::new();

if cmd_args.len() == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not entirely sure about the logic following this. If cmd_args is empty, then return empty? when would this happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If no cmd_args are provided (e.g. input is &[]), the let executable = cmd_args[0]; line would fail. Because of the data type of cmd_args is &[&str], providing an empty slice as the input is definitely possible (maybe to denote for no cmd_args supplied). In that case, there would be no byproducts and an empty BTreeMap would be returned.

return Ok(byproducts)
}

let executable = cmd_args[0];
let args = (&cmd_args[1..])
.iter()
Expand Down Expand Up @@ -167,8 +174,7 @@ pub fn run_command(cmd_args: &[&str], run_dir: Option<&str>) -> Result<BTreeMap<
io::stdout().write_all(&output.stdout)?;
io::stderr().write_all(&output.stderr)?;

// Format output into Byproduct
let mut byproducts: BTreeMap<String, String> = BTreeMap::new();

// Write to byproducts
let stdout = match String::from_utf8(output.stdout) {
Ok(output) => output,
Expand Down