@@ -17,7 +17,7 @@ import (
1717 "github.com/jfrog/jfrog-cli-core/v2/utils/config"
1818 "github.com/jfrog/jfrog-client-go/artifactory"
1919 "github.com/jfrog/jfrog-client-go/artifactory/services"
20- serviceutils "github.com/jfrog/jfrog-client-go/artifactory/services/utils"
20+
2121 "github.com/jfrog/jfrog-client-go/utils/log"
2222)
2323
@@ -131,11 +131,8 @@ func (pc *PublishCommand) Run() error {
131131 return fmt .Errorf ("failed to compute SHA256: %w" , err )
132132 }
133133
134- targetProps := fmt .Sprintf ("skill.name=%s;skill.description=%s;skill.version=%s" ,
135- slug , escapePropertyValue (meta .Description ), version )
136-
137134 target := fmt .Sprintf ("%s/%s/%s/" , pc .repoKey , slug , version )
138- if err := pc .upload (zipPath , target , targetProps ); err != nil {
135+ if err := pc .upload (zipPath , target ); err != nil {
139136 return fmt .Errorf ("upload failed: %w" , err )
140137 }
141138
@@ -260,6 +257,7 @@ func zipSkillFolder(skillDir, slug, version string) (string, error) {
260257 }
261258
262259 zipPath := filepath .Join (tmpDir , fmt .Sprintf ("%s-%s.zip" , slug , version ))
260+ // #nosec G304 -- path is constructed from controlled temp directory and user-provided slug
263261 zipFile , err := os .Create (zipPath )
264262 if err != nil {
265263 return "" , fmt .Errorf ("failed to create zip file: %w" , err )
@@ -306,7 +304,7 @@ func zipSkillFolder(skillDir, slug, version string) (string, error) {
306304 return err
307305 }
308306
309- // #nosec G304 -- Path is constructed from user-provided skill directory
307+ // #nosec G304,G122 -- path is from user-provided skill directory via filepath.Walk
310308 file , err := os .Open (path )
311309 if err != nil {
312310 return err
@@ -358,7 +356,7 @@ func computeSHA256(path string) (string, error) {
358356 return hex .EncodeToString (h .Sum (nil )), nil
359357}
360358
361- func (pc * PublishCommand ) upload (zipPath , target , targetProps string ) error {
359+ func (pc * PublishCommand ) upload (zipPath , target string ) error {
362360 serviceManager , err := utils .CreateUploadServiceManager (pc .serverDetails , 1 , 3 , 0 , false , nil )
363361 if err != nil {
364362 return err
@@ -368,14 +366,6 @@ func (pc *PublishCommand) upload(zipPath, target, targetProps string) error {
368366 uploadParams .Pattern = zipPath
369367 uploadParams .Target = target
370368 uploadParams .Flat = true
371- props := serviceutils .NewProperties ()
372- for _ , prop := range strings .Split (targetProps , ";" ) {
373- parts := strings .SplitN (prop , "=" , 2 )
374- if len (parts ) == 2 {
375- props .AddProperty (parts [0 ], parts [1 ])
376- }
377- }
378- uploadParams .TargetProps = props
379369
380370 _ , _ , err = serviceManager .UploadFiles (artifactory.UploadServiceOptions {}, uploadParams )
381371 return err
@@ -441,20 +431,13 @@ func (pc *PublishCommand) attachEvidence(slug, version, sha256Hex string) {
441431 log .Info ("Evidence successfully attached." )
442432}
443433
444- func escapePropertyValue (val string ) string {
445- val = strings .ReplaceAll (val , ";" , "\\ ;" )
446- val = strings .ReplaceAll (val , "=" , "\\ =" )
447- return val
448- }
449-
450434// RunPublish is the CLI action for `jf skills publish`.
451435func RunPublish (c * components.Context ) error {
452- if c .GetNumberOfArgs () < 2 {
453- return fmt .Errorf ("usage: jf skills publish <path-to-skill-folder> <repo> [options]" )
436+ if c .GetNumberOfArgs () < 1 {
437+ return fmt .Errorf ("usage: jf skills publish <path-to-skill-folder> [--repo <repo>] [options]" )
454438 }
455439
456440 skillDir := c .GetArgumentAt (0 )
457- repoKey := c .GetArgumentAt (1 )
458441 absDir , err := filepath .Abs (skillDir )
459442 if err != nil {
460443 return fmt .Errorf ("invalid skill path: %w" , err )
@@ -470,14 +453,20 @@ func RunPublish(c *components.Context) error {
470453 return err
471454 }
472455
456+ quiet := common .IsQuiet (c )
457+ repoKey , err := common .ResolveRepo (serverDetails , c .GetStringFlagValue ("repo" ), quiet )
458+ if err != nil {
459+ return err
460+ }
461+
473462 cmd := NewPublishCommand ().
474463 SetServerDetails (serverDetails ).
475464 SetRepoKey (repoKey ).
476465 SetSkillDir (absDir ).
477466 SetVersion (c .GetStringFlagValue ("version" )).
478467 SetSigningKey (c .GetStringFlagValue ("signing-key" )).
479468 SetKeyAlias (c .GetStringFlagValue ("key-alias" )).
480- SetQuiet (common . IsQuiet ( c ) )
469+ SetQuiet (quiet )
481470
482471 return cmd .Run ()
483472}
0 commit comments