Skip to content

Commit 94382ea

Browse files
committed
Merge branch 'gh-1207/main/fix-support-securestring' of https://github.com/Gijsreyn/operation-methods into gh-1207/main/fix-support-securestring
2 parents 699d809 + cc35c35 commit 94382ea

38 files changed

+1055
-929
lines changed

build.data.json

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -389,25 +389,7 @@
389389
"TestOnly": true,
390390
"CopyFiles": {
391391
"All": [
392-
"dscdelete.dsc.resource.json",
393-
"dscexist.dsc.resource.json",
394-
"dscexitcode.dsc.resource.json",
395-
"dscexport.dsc.resource.json",
396-
"dscexporter.dsc.resource.json",
397-
"dscget.dsc.resource.json",
398-
"dscindesiredstate.dsc.resource.json",
399-
"dscoperation.dsc.resource.json",
400-
"dscsleep.dsc.resource.json",
401-
"dsctrace.dsc.resource.json",
402-
"dscwhatif.dsc.resource.json",
403-
"metadata.dsc.resource.json",
404-
"resourceadapter.dsc.resource.json",
405-
"version1.1.2.dsc.resource.json",
406-
"version1.1.3.dsc.resource.json",
407-
"version1.1.dsc.resource.json",
408-
"version2.1p1.dsc.resource.json",
409-
"version2.1p2.dsc.resource.json",
410-
"version2.dsc.resource.json"
392+
"dsctest.dsc.manifests.json"
411393
]
412394
}
413395
},

build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,11 @@ if (!$SkipBuild) {
499499
}
500500

501501
if ($IsWindows) {
502-
Copy-Item "*.dsc.resource.json" $target -Force -ErrorAction Ignore
502+
Copy-Item "*.dsc.resource.*","*.dsc.manifests.*" $target -Force -ErrorAction Ignore
503503
}
504504
else { # don't copy WindowsPowerShell resource manifest
505505
$exclude = @('windowspowershell.dsc.resource.json', 'winpsscript.dsc.resource.json')
506-
Copy-Item "*.dsc.resource.json" $target -Exclude $exclude -Force -ErrorAction Ignore
506+
Copy-Item "*.dsc.resource.*","*.dsc.manifests.*" $target -Exclude $exclude -Force -ErrorAction Ignore
507507
}
508508

509509
# be sure that the files that should be executable are executable

dsc/src/args.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -289,20 +289,21 @@ pub enum ResourceSubCommand {
289289

290290
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
291291
pub enum SchemaType {
292-
GetResult,
293-
SetResult,
294-
TestResult,
295-
ResolveResult,
296-
DscResource,
297-
Resource,
298-
ResourceManifest,
299-
Include,
300292
Configuration,
301293
ConfigurationGetResult,
302294
ConfigurationSetResult,
303295
ConfigurationTestResult,
304-
ExtensionManifest,
296+
DscResource,
305297
ExtensionDiscoverResult,
298+
ExtensionManifest,
306299
FunctionDefinition,
307-
RestartRequired
300+
GetResult,
301+
Include,
302+
ManifestList,
303+
ResolveResult,
304+
Resource,
305+
ResourceManifest,
306+
RestartRequired,
307+
SetResult,
308+
TestResult,
308309
}

dsc/src/util.rs

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ use dsc_lib::{
1717
ResourceTestResult,
1818
},
1919
},
20-
discovery::Discovery,
20+
discovery::{
21+
command_discovery::ManifestList,
22+
Discovery,
23+
},
2124
dscerror::DscError,
2225
dscresources::{
2326
command_resource::TraceLevel,
@@ -157,30 +160,6 @@ pub fn add_fields_to_json(json: &str, fields_to_add: &HashMap<String, String>) -
157160
#[must_use]
158161
pub fn get_schema(schema: SchemaType) -> Schema {
159162
match schema {
160-
SchemaType::GetResult => {
161-
schema_for!(GetResult)
162-
},
163-
SchemaType::SetResult => {
164-
schema_for!(SetResult)
165-
},
166-
SchemaType::TestResult => {
167-
schema_for!(TestResult)
168-
},
169-
SchemaType::ResolveResult => {
170-
schema_for!(ResolveResult)
171-
}
172-
SchemaType::DscResource => {
173-
schema_for!(DscResource)
174-
},
175-
SchemaType::Resource => {
176-
schema_for!(Resource)
177-
},
178-
SchemaType::ResourceManifest => {
179-
schema_for!(ResourceManifest)
180-
},
181-
SchemaType::Include => {
182-
schema_for!(Include)
183-
},
184163
SchemaType::Configuration => {
185164
schema_for!(Configuration)
186165
},
@@ -193,18 +172,45 @@ pub fn get_schema(schema: SchemaType) -> Schema {
193172
SchemaType::ConfigurationTestResult => {
194173
schema_for!(ConfigurationTestResult)
195174
},
196-
SchemaType::ExtensionManifest => {
197-
schema_for!(ExtensionManifest)
175+
SchemaType::DscResource => {
176+
schema_for!(DscResource)
198177
},
199178
SchemaType::ExtensionDiscoverResult => {
200179
schema_for!(DiscoverResult)
201180
},
181+
SchemaType::ExtensionManifest => {
182+
schema_for!(ExtensionManifest)
183+
},
202184
SchemaType::FunctionDefinition => {
203185
schema_for!(FunctionDefinition)
204186
},
187+
SchemaType::GetResult => {
188+
schema_for!(GetResult)
189+
},
190+
SchemaType::Include => {
191+
schema_for!(Include)
192+
},
193+
SchemaType::ManifestList => {
194+
schema_for!(ManifestList)
195+
},
196+
SchemaType::ResolveResult => {
197+
schema_for!(ResolveResult)
198+
},
199+
SchemaType::Resource => {
200+
schema_for!(Resource)
201+
},
202+
SchemaType::ResourceManifest => {
203+
schema_for!(ResourceManifest)
204+
},
205205
SchemaType::RestartRequired => {
206206
schema_for!(RestartRequired)
207-
}
207+
},
208+
SchemaType::SetResult => {
209+
schema_for!(SetResult)
210+
},
211+
SchemaType::TestResult => {
212+
schema_for!(TestResult)
213+
},
208214
}
209215
}
210216

lib/dsc-lib-registry/src/lib.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,22 @@ impl RegistryHelper {
259259
///
260260
/// * `RegistryError` - The error that occurred.
261261
pub fn remove(&self) -> Result<Option<Registry>, RegistryError> {
262-
let (reg_key, _subkey) = match self.open(Security::AllAccess) {
262+
// For deleting a value, we need SetValue permission (KEY_SET_VALUE).
263+
// Try to open with the minimal required permission.
264+
// If that fails due to permission, try with AllAccess as a fallback.
265+
let (reg_key, _subkey) = match self.open(Security::SetValue) {
263266
Ok(reg_key) => reg_key,
264267
// handle NotFound error
265268
Err(RegistryError::RegistryKeyNotFound(_)) => {
266269
eprintln!("{}", t!("registry_helper.removeErrorKeyNotExist"));
267270
return Ok(None);
268271
},
272+
Err(RegistryError::RegistryKey(key::Error::PermissionDenied(_, _))) => {
273+
match self.open(Security::AllAccess) {
274+
Ok(reg_key) => reg_key,
275+
Err(e) => return self.handle_error_or_what_if(e),
276+
}
277+
},
269278
Err(e) => return self.handle_error_or_what_if(e),
270279
};
271280

@@ -289,10 +298,11 @@ impl RegistryHelper {
289298
Err(e) => return self.handle_error_or_what_if(RegistryError::RegistryValue(e)),
290299
}
291300
} else {
292-
// to delete the key, we need to open the parent key first
301+
// to delete the key, we need to open the parent key with CreateSubKey permission
302+
// which includes the ability to delete subkeys
293303
let parent_path = get_parent_key_path(&self.config.key_path);
294304
let (hive, parent_subkey) = get_hive_from_path(parent_path)?;
295-
let parent_reg_key = match hive.open(parent_subkey, Security::AllAccess) {
305+
let parent_reg_key = match hive.open(parent_subkey, Security::CreateSubKey) {
296306
Ok(k) => k,
297307
Err(e) => return self.handle_error_or_what_if(RegistryError::RegistryKey(e)),
298308
};

lib/dsc-lib/locales/en-us.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,16 @@ discoverResources = "Discovering '%{kind}' using filter: %{filter}"
9898
invalidAdapterFilter = "Could not build Regex filter for adapter name"
9999
progressSearching = "Searching for resources"
100100
extensionSearching = "Searching for extensions"
101-
foundResourceManifest = "Found resource manifest: %{path}"
101+
foundManifest = "Found manifest: %{path}"
102102
extensionFound = "Extension '%{extension}' version %{version} found"
103103
adapterFound = "Resource adapter '%{adapter}' version %{version} found"
104104
resourceFound = "Resource '%{resource}' version %{version} found"
105105
executableNotFound = "Executable '%{executable}' not found for operation '%{operation}' for resource '%{resource}'"
106106
extensionInvalidVersion = "Extension '%{extension}' version '%{version}' is invalid"
107-
invalidManifest = "Invalid manifest for resource '%{resource}'"
107+
invalidResourceManifest = "Invalid manifest for resource '%{resource}'"
108+
invalidExtensionManifest = "Invalid manifest for extension '%{extension}'"
109+
invalidManifestList = "Invalid manifest list '%{resource}': %{err}"
110+
invalidManifestFile = "Invalid manifest file '%{resource}': %{err}"
108111
extensionResourceFound = "Extension found resource '%{resource}'"
109112
callingExtension = "Calling extension '%{extension}' to discover resources"
110113
extensionFoundResources = "Extension '%{extension}' found %{count} resources"
@@ -677,3 +680,4 @@ notFoundSetting = "Setting '%{name}' not found in %{path}"
677680
failedToGetExePath = "Can't get 'dsc' executable path"
678681
settingNotFound = "Setting '%{name}' not found"
679682
failedToAbsolutizePath = "Failed to absolutize path '%{path}'"
683+
invalidExitCodeKey = "Invalid exit code key '%{key}'"

0 commit comments

Comments
 (0)