Skip to content

Commit aae42e4

Browse files
Merge branch 'main' into cmk-fips-api-signing
2 parents 6d08b6c + 9f4cecf commit aae42e4

411 files changed

Lines changed: 16622 additions & 8141 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.asf.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
github:
19+
description: "Apache Cloudstack Cloudmonkey"
20+
homepage: https://cloudstack.apache.org
21+
labels:
22+
- go
23+
- golang
24+
- cloudstack
25+
features:
26+
wiki: true
27+
issues: true
28+
projects: true
29+
30+
protected_branches:
31+
main: {}
32+
33+
copilot_code_review:
34+
enabled: true
35+
review_drafts: true
36+
review_on_push: true

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
run: |
108108
mvn -q -Pdeveloper -pl developer -Ddeploydb
109109
mvn -q -Pdeveloper -pl developer -Ddeploydb-simulator
110-
python3 -m pip install --user --upgrade tools/marvin/dist/Marvin-*.tar.gz
110+
python3 -m pip install --user --upgrade tools/marvin/dist/[mM]arvin-*.tar.gz
111111
112112
- name: Start CloudStack mgmt (Jetty) in background
113113
id: start_ms

.rat-excludes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ apache-rat-0.17
44
go.sum
55
rat-report.txt
66
/snap/snapcraft.yaml
7-
vendor
7+
vendor
8+
**/*.patch

AGENTS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- SPDX-License-Identifier: Apache-2.0 -->
2+
3+
# Agent Guide for cloudstack-cloudmonkey
4+
5+
This file is read by automated agents (security scanners, code analyzers,
6+
AI assistants) operating on this repository.
7+
8+
## Security
9+
10+
Security model: [SECURITY.md](./SECURITY.md)
11+
12+
Agents that scan this repository should consult `SECURITY.md` and the
13+
project-wide threat model it links before reporting issues.

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ run: all
4848
debug:
4949
$(GO) build -mod=vendor -gcflags='-N -l' -o cmk && dlv --listen=:2345 --headless=true --api-version=2 exec ./cmk
5050

51+
.PHONY: vendor-patch
52+
vendor-patch: ## Refresh vendor/ and re-apply the local patches in patches/
53+
$(info $(M) Refreshing vendor/ and re-applying local patches…)
54+
$Q $(GO) mod vendor
55+
$Q for p in patches/*.patch; do git apply "$$p" || exit 1; done
56+
$Q echo "$(M) Done! See patches/README.md"
57+
58+
.PHONY: vendor-check
59+
vendor-check: ## Verify vendor/ still carries the local patches in patches/
60+
$(info $(M) Checking local patches are present in vendor/…)
61+
$Q for p in patches/*.patch; do \
62+
git apply --reverse --check "$$p" || { \
63+
echo "ERROR: $$p is not applied to vendor/; run 'make vendor-patch'"; exit 1; }; \
64+
done
65+
$Q echo "$(M) All local patches present"
66+
5167
dist-mkdir: all
5268
rm -fr dist
5369
mkdir -p dist

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ If cloudmonkey is being upgraded from a version lower than v6.0.0, it must be no
7979
that the cloudmonkey configuration path is changed from `~/.cloudmonkey/config` to
8080
`~/.cmk/config` and a default `localcloud` profile is created. One must first set up basic configurations such as apikey/secretkey/username/password/url for the required profile(s) as required
8181

82+
### Environment Variables
83+
84+
`cmk` supports environment variables that mirror its CLI flags. CLI flags take
85+
precedence over environment variables, which take precedence over values in the
86+
config file.
87+
88+
| Environment variable | Flag | Description |
89+
|----------------------|------|-------------|
90+
| `CMK_CONFIG` | `-c` | Config file path |
91+
| `CMK_PROFILE` | `-p` | Server profile |
92+
| `CMK_URL` | `-u` | CloudStack's API endpoint URL |
93+
| `CMK_API_KEY` | `-k` | CloudStack user's API key |
94+
| `CMK_SECRET_KEY` | `-s` | CloudStack user's secret key |
95+
| `CMK_OUTPUT` | `-o` | API response output format |
96+
| `CMK_DEBUG` | `-d` | Enable debug mode when set to a boolean true value (e.g. `true` or `1`) |
97+
98+
`CMK_CONFIG` must point to an existing config file, and `CMK_PROFILE` must name
99+
an existing profile in the config; otherwise `cmk` exits with an error. A profile
100+
selected via `CMK_PROFILE` applies only to that invocation and is not persisted
101+
to the config file.
102+
82103
### License
83104

84105
Licensed to the Apache Software Foundation (ASF) under one

SECURITY.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!--
2+
SPDX-License-Identifier: Apache-2.0
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
# Security Policy
18+
19+
## Reporting a Vulnerability
20+
21+
`apache/cloudstack-cloudmonkey` follows the [Apache Software Foundation security process](https://www.apache.org/security/).
22+
Please report suspected vulnerabilities privately to `security@apache.org`; do not
23+
open public GitHub issues or pull requests for security reports.
24+
25+
## Threat Model
26+
27+
`apache/cloudstack-cloudmonkey` is part of the Apache CloudStack project and is covered by the
28+
**project-wide CloudStack threat model** rather than a per-repository copy. What the
29+
project treats as in scope and out of scope, the security properties it provides and
30+
disclaims, the adversary model, and how findings are triaged are documented in that
31+
model: <https://github.com/apache/cloudstack/blob/main/THREAT_MODEL.md>.
32+
33+
(That link resolves once the project-wide model lands on `apache/cloudstack`'s
34+
`main` branch — see apache/cloudstack#13293. A thin `cloudstack-cloudmonkey`-specific
35+
addendum can be added here later if this component needs one.)

cli/completer.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,22 @@ func findAPI(apiMap map[string][]*config.API, relatedNoun string) *config.API {
208208
return autocompleteAPI
209209
}
210210

211+
// pluralizeNoun applies simple English pluralization rules used by the
212+
// autocomplete heuristics below (e.g., policy -> policies, disk -> disks).
213+
func pluralizeNoun(noun string) string {
214+
switch {
215+
case strings.HasSuffix(noun, "ies"):
216+
return noun
217+
case strings.HasSuffix(noun, "y") && len(noun) > 1 && !strings.ContainsAny(string(noun[len(noun)-2]), "aeiou"):
218+
// Handle words ending in consonant + y (e.g., policy -> policies)
219+
return noun[:len(noun)-1] + "ies"
220+
case strings.HasSuffix(noun, "s") || strings.HasSuffix(noun, "x") || strings.HasSuffix(noun, "z") || strings.HasSuffix(noun, "ch") || strings.HasSuffix(noun, "sh"):
221+
return noun + "es"
222+
default:
223+
return noun + "s"
224+
}
225+
}
226+
211227
func findAutocompleteAPI(arg *config.APIArg, apiFound *config.API, apiMap map[string][]*config.API) *config.API {
212228
if arg.Type == "map" {
213229
return nil
@@ -220,8 +236,9 @@ func findAutocompleteAPI(arg *config.APIArg, apiFound *config.API, apiMap map[st
220236
case argName == "id" || argName == "ids":
221237
// Heuristic: user is trying to autocomplete for id/ids arg for a list API
222238
relatedNoun = apiFound.Noun
223-
if apiFound.Verb != "list" {
224-
relatedNoun += "s"
239+
if apiFound.Verb != "list" && findAPI(apiMap, relatedNoun) == nil {
240+
// Noun may already be plural (e.g. bulk ops like deleteAlerts)
241+
relatedNoun = pluralizeNoun(relatedNoun)
225242
}
226243
case argName == "account":
227244
// Heuristic: user is trying to autocomplete for accounts
@@ -249,12 +266,7 @@ func findAutocompleteAPI(arg *config.APIArg, apiFound *config.API, apiMap map[st
249266
}
250267
}
251268
}
252-
// Handle common cases where base ends with a vowel and needs "es"
253-
if strings.HasSuffix(base, "s") || strings.HasSuffix(base, "x") || strings.HasSuffix(base, "z") || strings.HasSuffix(base, "ch") || strings.HasSuffix(base, "sh") {
254-
relatedNoun = base + "es"
255-
} else {
256-
relatedNoun = base + "s"
257-
}
269+
relatedNoun = pluralizeNoun(base)
258270
}
259271

260272
config.Debug("Possible related noun for the arg: ", relatedNoun, " and type: ", arg.Type)

cli/prompt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"strings"
2424

2525
"github.com/apache/cloudstack-cloudmonkey/config"
26-
"github.com/chzyer/readline"
26+
"github.com/ergochat/readline"
2727
)
2828

2929
// CLI config instance

cmd/command.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,15 @@ CloudMonkey (cmk) 🐵 is a command line interface for Apache CloudStack.
6565
Allowed flags:
6666
-h Show this help message or API doc when specified after an API
6767
-v Print version
68-
-o API response output format: json, text, table, column, csv
69-
-p Server profile
70-
-d Enable debug mode
71-
-c Different config file path
72-
-u CloudStack's API endpoint URL
73-
-s CloudStack user's secret Key
74-
-k CloudStack user's API Key
68+
-o API response output format: json, text, table, column, csv (env: CMK_OUTPUT)
69+
-p Server profile (env: CMK_PROFILE)
70+
-d Enable debug mode (env: CMK_DEBUG)
71+
-c Different config file path (env: CMK_CONFIG)
72+
-u CloudStack's API endpoint URL (env: CMK_URL)
73+
-s CloudStack user's secret key (env: CMK_SECRET_KEY)
74+
-k CloudStack user's API key (env: CMK_API_KEY)
75+
76+
CLI flags take precedence over their environment variables.
7577
7678
Default commands:
7779
%s

0 commit comments

Comments
 (0)