Skip to content

Use a default temp folder for keys and certs#1

Open
vthiebaut10 wants to merge 4 commits intossharcfrom
ssharc-security
Open

Use a default temp folder for keys and certs#1
vthiebaut10 wants to merge 4 commits intossharcfrom
ssharc-security

Conversation

@vthiebaut10
Copy link
Owner


This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally?

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your PR is merged into master branch, a new PR will be created to update src/index.json automatically.
The precondition is to put your code inside this repo and upgrade the version in the PR but do not modify src/index.json.

CLIENT_PROXY_STORAGE_URL = "https://sshproxysa.blob.core.windows.net"
CLEANUP_TOTAL_TIME_LIMIT_IN_SECONDS = 120
CLEANUP_TIME_INTERVAL_IN_SECONDS = 10
DEFAULT_KEY_TEMPDIR_NAME = "azclisshkeys"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call it as DEFAULT_TEMPDIR.
We will store keys, relay information, etc in this folder.

ssh_utils.create_ssh_keyfile(private_key_file)
if not os.path.isdir(temp_dir):
new_temp_dir = tempfile.mkdtemp()
os.rename(new_temp_dir, os.path.join(os.path.dirname(new_temp_dir), consts.DEFAULT_KEY_TEMPDIR_NAME))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why can't we create the temp directory with the desired name. What's the need for rename?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree that's a little weird. But the way this tempfile library works is that we can provide a prefix and/or a suffix for the name, but they are gonna add some random characters in the middle. So I just rename it instead so we don't have to deal with that.

new_temp_dir = tempfile.mkdtemp()
os.rename(new_temp_dir, os.path.join(os.path.dirname(new_temp_dir), consts.DEFAULT_KEY_TEMPDIR_NAME))
if not os.path.isfile(public_key_file) or not os.path.isfile(private_key_file):
# file_utils.delete_file(public_key_file, f"Couldn't delete existing public key {public_key_file}. ")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good idea to delete existing files as we enter if one of the file doesn't exist.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssh-keygen seems to be overwriting any existing key files with the same name, so I don't think it's necessary, but I agree that it is a good idea to do it anyways.

vthiebaut10 pushed a commit that referenced this pull request May 23, 2024
* fix: --title --kind --custom-property parameters (#1)

* feat: support yaml file in register command (#3)

* fix: workspace parameter should not be required (#2)

* style: fix lint issues (#6)

* chore: update codeowner for apic-extension (#5)

* feat: revert changes to min cli version (#4)

* feat: resolve comments to CLI experience (#10)

* feat: mark "apic api register" command as preview (#13)

* feat: remove --terms-of-service parameter (#12)

* feat: remove --workspace-name parameter (#11)

* feat: support python 3.8 and 3.9 (#14)

* feat: fix command descriptions (#17)

* tests: add test cases for 'apic service' commands (#16)

* feat: Use 03-01 spec from azure-rest-api-specs repo to regenerate CLI (#19)

* fix: CLI errors (#20)

* fix: import error when run CLI command

* fix: no workspace name error when run import specification command

* feat: mark some parameters as required (#21)

* feat: mark --assignments parameter required for metadata commands

* doc: update sample commands

* feat: mark --source-resource-ids parameter as required for import-from-apim command

* doc: update description for import-from-apim command

* feat: bump version to 1.0.0b5 and update changelog (#18)

* build: fix ci (#22)

* style: fix style warnings

* test:fix test cases

* fix: service update command failure (#28)

* doc: fix command samples (#30)

* doc: update changelog per feedback (#29)

* doc: remove extra spaces in register command help message (#34)

* doc: update api definition and metadata command samples (Azure#36)
vthiebaut10 pushed a commit that referenced this pull request Jun 27, 2025
* add pester tests for k8s-configuration

* Add api version 2024-11-01 with provider support for git repository (#1)

* Delete testing directory

---------

Co-authored-by: Bavneet Singh <bavneetsingh@microsoft.com>
vthiebaut10 pushed a commit that referenced this pull request Feb 6, 2026
…ommands for replication (Azure#9493)

* Adding "Migrate" folder to the project

* Added migrate command

* Adding preview tag for commands, moving migration to a seperate folder & update help text.

* Addressing style issues

* addressing the styles and removing the duplicate key

* addressing style issues

* addesssing more style issues

* addressing  inline disable at the specific line

* Added R1702 to the pylint disable comment on the function definition.

* Addressing to disable too many nested blocks R1702

* Fixing test cases and updating version changes

* Add cli fixes (#1)

* Create extension

* Update src/migrate/azext_migrate/__init__.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix import issues

* Update src/migrate/setup.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Small

* Small lint

* Small

* disable lint for this check

* Add json

* Fix licesnse issue

* fix small

* Small

* Get rid of unused variables

* Add service name and code owner

* New version

* Style

* Small

* Update

* Follow standard

* Add suggestions

* Small

* Not preview

* Add flag to become experimental

* Update history

* Fix

* small

* Create get job and remove replication commands

* Add better error handling for jobs command

* Add better messages to remove protected item

* Return job id in remove command

* Move helpers

* Rename get discovered server helper

* Refactor _initialize_replication_infrastructure_helpers

* Refactor new replication

* Refactor jobs

* Refactor delete protected item

* Fix lint issues

* Change release version

* Fix lint issues

* Add fix

* Updae correct version

* Put beta version before

* Fix

* Update

* Fix bifurcation tool issue

* Update amh correctly if not proper

* Use current subscription id if not passed in

* Fix correct location and target resource group creation

* Create list protected items command

* Update versions

* Add __init__.py to all folders

* Create unit tests for get replication

* Update readme with accurate description of commands

* Update readme

* Create tests for jobs and remove commands

* Add more tests to increase coverage to 74%

* Add start migration command

* Address fixes

* Remove doc strings from custom.py

* Add init

* Remove old file locations

* fix failing tests

* Fix secret test

* Fix test

* Fix secret detection

* Fix duplicates

---------

Co-authored-by: Saif Al-Din Ali <saifaldinali@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Saif Al-Din Ali <saif-canada@hotmail.com>
Co-authored-by: Saif Al-Din Ali <saifaldinali@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants