@@ -10,6 +10,13 @@ audit_meta!(UnpinnedUses, "unpinned-uses", "unpinned action reference");
1010
1111impl UnpinnedUses {
1212 pub fn evaluate_pinning < ' u > ( & self , uses : & Uses ) -> Option < ( & ' u str , Severity , Persona ) > {
13+ // Don't evaluate pinning for local `uses:`, since unpinned references
14+ // are fully controlled by the repository anyways.
15+ // TODO: auditor-level findings instead, perhaps?
16+ if matches ! ( uses, Uses :: Local ( _) ) {
17+ return None ;
18+ }
19+
1320 if uses. unpinned ( ) {
1421 Some ( (
1522 "action is not pinned to a tag, branch, or hash ref" ,
@@ -43,24 +50,22 @@ impl Audit for UnpinnedUses {
4350 return Ok ( vec ! [ ] ) ;
4451 } ;
4552
46- let Some ( ( annotation, severity, persona) ) = self . evaluate_pinning ( uses) else {
47- return Ok ( vec ! [ ] ) ;
53+ if let Some ( ( annotation, severity, persona) ) = self . evaluate_pinning ( uses) {
54+ findings. push (
55+ Self :: finding ( )
56+ . confidence ( Confidence :: High )
57+ . severity ( severity)
58+ . persona ( persona)
59+ . add_location (
60+ step. location ( )
61+ . primary ( )
62+ . with_keys ( & [ "uses" . into ( ) ] )
63+ . annotated ( annotation) ,
64+ )
65+ . build ( step. workflow ( ) ) ?,
66+ ) ;
4867 } ;
4968
50- findings. push (
51- Self :: finding ( )
52- . confidence ( Confidence :: High )
53- . severity ( severity)
54- . persona ( persona)
55- . add_location (
56- step. location ( )
57- . primary ( )
58- . with_keys ( & [ "uses" . into ( ) ] )
59- . annotated ( annotation) ,
60- )
61- . build ( step. workflow ( ) ) ?,
62- ) ;
63-
6469 Ok ( findings)
6570 }
6671
@@ -74,24 +79,22 @@ impl Audit for UnpinnedUses {
7479 return Ok ( vec ! [ ] ) ;
7580 } ;
7681
77- let Some ( ( annotation, severity, persona) ) = self . evaluate_pinning ( uses) else {
78- return Ok ( vec ! [ ] ) ;
82+ if let Some ( ( annotation, severity, persona) ) = self . evaluate_pinning ( uses) {
83+ findings. push (
84+ Self :: finding ( )
85+ . confidence ( Confidence :: High )
86+ . severity ( severity)
87+ . persona ( persona)
88+ . add_location (
89+ step. location ( )
90+ . primary ( )
91+ . with_keys ( & [ "uses" . into ( ) ] )
92+ . annotated ( annotation) ,
93+ )
94+ . build ( step. action ( ) ) ?,
95+ ) ;
7996 } ;
8097
81- findings. push (
82- Self :: finding ( )
83- . confidence ( Confidence :: High )
84- . severity ( severity)
85- . persona ( persona)
86- . add_location (
87- step. location ( )
88- . primary ( )
89- . with_keys ( & [ "uses" . into ( ) ] )
90- . annotated ( annotation) ,
91- )
92- . build ( step. action ( ) ) ?,
93- ) ;
94-
9598 Ok ( findings)
9699 }
97100}
0 commit comments