Skip to content

Commit 69874a5

Browse files
committed
Add signature verification metadata
1 parent a392ea4 commit 69874a5

9 files changed

Lines changed: 413 additions & 78 deletions

File tree

cmd/bucket.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ var bucketCmd = &cobra.Command{
1717
Long: `Manage APK repository buckets (sources) for the client functionality.`,
1818
}
1919

20+
var bucketVerifySignature bool
21+
2022
var bucketListCmd = &cobra.Command{
2123
Use: "list",
2224
Short: "List all configured buckets",
@@ -108,6 +110,7 @@ var bucketAddCmd = &cobra.Command{
108110
// Update bucket index
109111
fmt.Printf("Fetching bucket manifest...\n")
110112
bucketMgr := client.NewBucketManager(config)
113+
bucketMgr.SetSignatureVerification(bucketVerifySignature && config.Security.VerifySignature)
111114
if _, err := bucketMgr.FetchManifest(name); err != nil {
112115
fmt.Printf("Warning: Failed to fetch manifest: %v\n", err)
113116
fmt.Println("You can try updating later with 'apkhub bucket update'")
@@ -169,6 +172,7 @@ var bucketUpdateCmd = &cobra.Command{
169172
}
170173

171174
bucketMgr := client.NewBucketManager(config)
175+
bucketMgr.SetSignatureVerification(bucketVerifySignature && config.Security.VerifySignature)
172176

173177
if len(args) > 0 {
174178
// Update specific bucket
@@ -517,6 +521,8 @@ func formatBytes(bytes int64) string {
517521
func init() {
518522
rootCmd.AddCommand(bucketCmd)
519523

524+
bucketCmd.PersistentFlags().BoolVar(&bucketVerifySignature, "verify-signature", true, "Verify bucket manifest signatures (set false to bypass)")
525+
520526
// Add subcommands
521527
bucketCmd.AddCommand(bucketListCmd)
522528
bucketCmd.AddCommand(bucketAddCmd)

cmd/update.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Examples:
2525
}
2626

2727
bucketMgr := client.NewBucketManager(config)
28+
bucketMgr.SetSignatureVerification(bucketVerifySignature && config.Security.VerifySignature)
2829

2930
if len(args) > 0 {
3031
// Update specific bucket
@@ -39,7 +40,7 @@ Examples:
3940
if updateAll {
4041
// Update all buckets including disabled ones
4142
fmt.Println("🔄 Updating all buckets (including disabled)...")
42-
43+
4344
for name := range config.Buckets {
4445
fmt.Printf("📡 Fetching '%s'...\n", name)
4546
if _, err := bucketMgr.FetchManifest(name); err != nil {
@@ -65,7 +66,8 @@ var updateAll bool
6566

6667
func init() {
6768
rootCmd.AddCommand(updateCmd)
68-
69+
6970
// Add flags
7071
updateCmd.Flags().BoolVar(&updateAll, "all", false, "Update all buckets including disabled ones")
71-
}
72+
updateCmd.Flags().BoolVar(&bucketVerifySignature, "verify-signature", true, "Verify bucket manifest signatures during update")
73+
}

0 commit comments

Comments
 (0)