-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding omnitrail attestor (#256)
* feat: adding omnitrail attestor --------- Signed-off-by: Frederick Kautz <[email protected]>
- Loading branch information
Showing
5 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2024 The Witness Contributors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package omnitrail | ||
|
||
import ( | ||
ot "github.com/fkautz/omnitrail-go" | ||
"github.com/in-toto/go-witness/attestation" | ||
"github.com/invopop/jsonschema" | ||
) | ||
|
||
const ( | ||
Name = "omnitrail" | ||
Type = "https://witness.dev/attestations/omnitrail/v0.1" | ||
RunType = attestation.PreMaterialRunType | ||
) | ||
|
||
func init() { | ||
attestation.RegisterAttestation(Name, Type, RunType, func() attestation.Attestor { | ||
return NewOmnitrailAttestor() | ||
}) | ||
} | ||
|
||
type Attestor struct { | ||
Envelope *ot.Envelope `json:"Envelope"` | ||
} | ||
|
||
func NewOmnitrailAttestor() *Attestor { | ||
return &Attestor{} | ||
} | ||
|
||
// Attest implements attestation.Attestor. | ||
func (o *Attestor) Attest(ctx *attestation.AttestationContext) error { | ||
trail := ot.NewTrail() | ||
err := trail.Add(ctx.WorkingDir()) | ||
if err != nil { | ||
return err | ||
} | ||
o.Envelope = trail.Envelope() | ||
return nil | ||
} | ||
|
||
// Name implements attestation.Attestor. | ||
func (o *Attestor) Name() string { | ||
return Name | ||
} | ||
|
||
// RunType implements attestation.Attestor. | ||
func (o *Attestor) RunType() attestation.RunType { | ||
return RunType | ||
} | ||
|
||
// // Schema implements attestation.Attestor. | ||
func (o *Attestor) Schema() *jsonschema.Schema { | ||
return jsonschema.Reflect(&o) | ||
} | ||
|
||
// Type implements attestation.Attestor. | ||
func (o *Attestor) Type() string { | ||
return Type | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$ref": "#/$defs/Attestor", | ||
"$defs": { | ||
"Attestor": { | ||
"properties": { | ||
"Envelope": { | ||
"$ref": "#/$defs/Envelope" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"type": "object", | ||
"required": [ | ||
"Envelope" | ||
] | ||
}, | ||
"Element": { | ||
"properties": { | ||
"type": { | ||
"type": "string" | ||
}, | ||
"sha1": { | ||
"type": "string" | ||
}, | ||
"sha256": { | ||
"type": "string" | ||
}, | ||
"gitoid:sha1": { | ||
"type": "string" | ||
}, | ||
"gitoid:sha256": { | ||
"type": "string" | ||
}, | ||
"posix": { | ||
"$ref": "#/$defs/Posix" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"type": "object", | ||
"required": [ | ||
"type" | ||
] | ||
}, | ||
"Envelope": { | ||
"properties": { | ||
"header": { | ||
"$ref": "#/$defs/Header" | ||
}, | ||
"mapping": { | ||
"additionalProperties": { | ||
"$ref": "#/$defs/Element" | ||
}, | ||
"type": "object" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"type": "object", | ||
"required": [ | ||
"header", | ||
"mapping" | ||
] | ||
}, | ||
"Feature": { | ||
"properties": { | ||
"algorithms": { | ||
"items": { | ||
"type": "string" | ||
}, | ||
"type": "array" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"type": "object" | ||
}, | ||
"Header": { | ||
"properties": { | ||
"features": { | ||
"additionalProperties": { | ||
"$ref": "#/$defs/Feature" | ||
}, | ||
"type": "object" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"type": "object", | ||
"required": [ | ||
"features" | ||
] | ||
}, | ||
"Posix": { | ||
"properties": { | ||
"atime": { | ||
"type": "string" | ||
}, | ||
"ctime": { | ||
"type": "string" | ||
}, | ||
"creation_time": { | ||
"type": "string" | ||
}, | ||
"extended_attributes": { | ||
"type": "string" | ||
}, | ||
"file_device_id": { | ||
"type": "string" | ||
}, | ||
"file_flags": { | ||
"type": "string" | ||
}, | ||
"file_inode": { | ||
"type": "string" | ||
}, | ||
"file_system_id": { | ||
"type": "string" | ||
}, | ||
"file_type": { | ||
"type": "string" | ||
}, | ||
"hard_link_count": { | ||
"type": "string" | ||
}, | ||
"mtime": { | ||
"type": "string" | ||
}, | ||
"metadata_ctime": { | ||
"type": "string" | ||
}, | ||
"owner_gid": { | ||
"type": "string" | ||
}, | ||
"owner_uid": { | ||
"type": "string" | ||
}, | ||
"permissions": { | ||
"type": "string" | ||
}, | ||
"size": { | ||
"type": "string" | ||
} | ||
}, | ||
"additionalProperties": false, | ||
"type": "object" | ||
} | ||
} | ||
} |