Repository: Azure/azure-cli-extensions

Issue:
blueprint: Import parses unwanted hidden files
### **This is autogenerated. Please review and update as needed.**

## Describe the bug
`blueprint` import will import all files in the `artifacts` folder including hidden Linux files and might raise an `UnicodeDecodeError` (eg. for Vim swap files which often include non-ASCII chars)

**Command Name**
`az blueprint import
Extension Name: blueprint. Version: 0.3.1.`

**Errors:**
```
The command failed with an unexpected error. Here is the traceback:
'utf-8' codec can't decode byte 0xfa in position 16: invalid start byte
Traceback (most recent call last):
  File "/home/generic_user/.venv_az/lib/python3.9/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/home/generic_user/.venv_az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
    raise ex
  File "/home/generic_user/.venv_az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/home/generic_user/.venv_az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
    result = cmd_copy(params)
  File "/home/generic_user/.venv_az/lib/python3.9/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
    return self.handler(*args, **kwargs)
  File "/home/generic_user/.venv_az/lib/python3.9/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/home/generic_user/.azure/cliextensions/blueprint/azext_blueprint/custom.py", line 53, in import_blueprint_with_artifacts
    artifact = json.load(artifact_file)
  File "/usr/lib/python3.9/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfa in position 16: invalid start byte
```

## To Reproduce:
- `vim generic_blueprint/artifacts/generic_artifact.json`
- `az blueprint import --name generic_blueprint --input-path ./generic_blueprint --management-group deadbeef-dead-beef-8badf00d1337`

## Expected Behavior
Import works flawlessly

## Environment Summary
```
Linux-5.10.102.1-microsoft-standard-WSL2-x86_64-with-glibc2.31, Debian GNU/Linux 11 (bullseye)
Python 3.9.2
Installer: PIP

azure-cli 2.37.0

Extensions:
blueprint 0.3.1
resource-graph 2.1.0
serial-console 0.1.1

Dependencies:
msal 1.18.0b1
azure-mgmt-resource 21.1.0b1
```
## Additional Context

<!--Please don't remove this:-->
<!--auto-generated-->




Discussion:

Resolving patch:
diff --git a/src/blueprint/azext_blueprint/custom.py b/src/blueprint/azext_blueprint/custom.py
--- a/src/blueprint/azext_blueprint/custom.py
+++ b/src/blueprint/azext_blueprint/custom.py
@@ -7,6 +7,7 @@
 
 import json
 import os
+import stat
 from knack.util import CLIError
 from azure.cli.core.util import user_confirmation
 from azure.core.exceptions import HttpResponseError
@@ -48,12 +49,15 @@ def import_blueprint_with_artifacts(cmd,
         for filename in os.listdir(os.path.join(input_path, 'artifacts')):
             artifact_name = filename.split('.')[0]
             filepath = os.path.join(input_path, 'artifacts', filename)
-            with open(filepath) as artifact_file:
-                try:
-                    artifact = json.load(artifact_file)
-                    art_dict[artifact_name] = artifact
-                except json.decoder.JSONDecodeError as ex:
-                    raise CLIError('JSON decode error for {}: {}'.format(filepath, str(ex))) from ex
+            # skip hidden files
+            if ((os.name != 'nt' and not filename.startswith('.')) or
+                    (os.name == 'nt' and not bool(os.stat(filepath).st_file_attributes & stat.FILE_ATTRIBUTE_HIDDEN))):
+                with open(filepath) as artifact_file:
+                    try:
+                        artifact = json.load(artifact_file)
+                        art_dict[artifact_name] = artifact
+                    except json.decoder.JSONDecodeError as ex:
+                        raise CLIError('JSON decode error for {}: {}'.format(filepath, str(ex))) from ex
     except FileNotFoundError as ex:
         raise CLIError('File not Found: {}'.format(str(ex))) from ex
 


Test patch: