@@ -53,6 +53,28 @@ async function sendSuccessStatusReport(
53
53
}
54
54
}
55
55
56
+ async function findSecuritySarifFiles ( sarifPath : string ) : Promise < string [ ] > {
57
+ if ( fs . lstatSync ( sarifPath ) . isDirectory ( ) ) {
58
+ return upload_lib . findSarifFilesInDir (
59
+ sarifPath ,
60
+ upload_lib . CodeScanningTarget . sarifPredicate ,
61
+ ) ;
62
+ }
63
+
64
+ return [ sarifPath ] ;
65
+ }
66
+
67
+ async function findQualitySarifFiles ( sarifPath : string ) : Promise < string [ ] > {
68
+ if ( fs . lstatSync ( sarifPath ) . isDirectory ( ) ) {
69
+ return upload_lib . findSarifFilesInDir (
70
+ sarifPath ,
71
+ upload_lib . CodeQualityTarget . sarifPredicate ,
72
+ ) ;
73
+ }
74
+
75
+ return [ ] ;
76
+ }
77
+
56
78
async function run ( ) {
57
79
const startedAt = new Date ( ) ;
58
80
const logger = getActionsLogger ( ) ;
@@ -89,8 +111,11 @@ async function run() {
89
111
const checkoutPath = actionsUtil . getRequiredInput ( "checkout_path" ) ;
90
112
const category = actionsUtil . getOptionalInput ( "category" ) ;
91
113
92
- const uploadResult = await upload_lib . uploadFiles (
93
- sarifPath ,
114
+ const securitySarifFiles = await findSecuritySarifFiles ( sarifPath ) ;
115
+ const qualitySarifFiles = await findQualitySarifFiles ( sarifPath ) ;
116
+
117
+ const uploadResult = await upload_lib . uploadSpecifiedFiles (
118
+ securitySarifFiles ,
94
119
checkoutPath ,
95
120
category ,
96
121
features ,
@@ -102,22 +127,15 @@ async function run() {
102
127
// If there are `.quality.sarif` files in `sarifPath`, then upload those to the code quality service.
103
128
// Code quality can currently only be enabled on top of security, so we'd currently always expect to
104
129
// have a directory for the results here.
105
- if ( fs . lstatSync ( sarifPath ) . isDirectory ( ) ) {
106
- const qualitySarifFiles = upload_lib . findSarifFilesInDir (
107
- sarifPath ,
108
- upload_lib . CodeQualityTarget . sarifPredicate ,
130
+ if ( qualitySarifFiles . length !== 0 ) {
131
+ await upload_lib . uploadSpecifiedFiles (
132
+ qualitySarifFiles ,
133
+ checkoutPath ,
134
+ category ,
135
+ features ,
136
+ logger ,
137
+ upload_lib . CodeQualityTarget ,
109
138
) ;
110
-
111
- if ( qualitySarifFiles . length !== 0 ) {
112
- await upload_lib . uploadSpecifiedFiles (
113
- qualitySarifFiles ,
114
- checkoutPath ,
115
- category ,
116
- features ,
117
- logger ,
118
- upload_lib . CodeQualityTarget ,
119
- ) ;
120
- }
121
139
}
122
140
123
141
// We don't upload results in test mode, so don't wait for processing
0 commit comments