Skip to main content

A python package to manage vscode extensions.

Project description

pyvscodeextroh

The pyvscodeextroh package can be used to manage VSCode extensions via policy file, remotely or via MDM solution.

Table of Contents

  1. Introduction
  2. Getting started
    1. Prerequisites
    2. Installation
  3. How to use
    1. How to import
    2. Using the module
  4. Releasing
  5. License

Introduction

While software, driver, hardware and everything else is managed by organizations, most of them, are not managing their dev environments at all.

With emerging threads in dev environments and software supply chain, managing dev environments is and will be crucial for organizations in the future.

This python package aims to centralize the extension management on linux dev environments for VSCode via remote connections or MDM solutions like Ansible.

You can find an overview of all policies here.

Getting started

Prerequisites

  • Python installed
  • Operatingsystem: Linux or Windows, not tested on mac
  • IDE like VS Code, if you want to contribute or change the code

Installation

There are two ways to install this module depending on the way you work and the preinstalled modules:

  1. pip install pyvscodeextroh
  2. python -m pip install pyvscodeextroh

How to use

How to import

You can import the module in two ways:

import pyvscodeextroh

This will import all functions. Even the ones that are not supposed to be used (helper functions).

from pyvscodeextroh import *

This will import only the significant functions, meant for using.

Using the module

You can do the following things:

  • Add/Remove extensions to policy file
  • Add/Remove publishers to policy file
  • Deny extensions/publishers via policy file
  • Install/Uninstall specific extensions
  • Enforce the current policy file

Every command requires sudo priviliges.

The following examples show how to use this package and its modules in a script.

Example 1: Add a publisher to the policy

With this code only extensions from MS can be installed on the current machine.

# Add a publisher
from pyvscodeextroh.policy_editor import PolicyEditor
# Create an editor
editor = PolicyEditor()
# Allow all extensions from the publisher "microsoft"
editor.allow_publisher("microsoft")

# Result:
# Creates the file /etc/vscode/policy.json if it does not exist
# Appends follwing lines
# "AllowedExtensions": {
#    "microsoft": true
# }

Example 2: Enforce VSCode policy

This will enforce a policy from the /etc/vscode/policy.json. It force uninstalls all unallowed extensions.

from pyvscodeextroh import VSCodePolicyManager
# Use the default system policy file (/etc/vscode/policy.json)
pm = VSCodePolicyManager()
# Uninstall all unallowed extensions
pm.enforce_policy()

You can also use a custom policy file, if you want extensions managed seperated from other configurations like MCP, AI, ... .

A custom policy file has to look like:

{
    "AllowedExtensions": {
        "microsoft": true,
        "github": true,
        "ms-python.python": true,
        "evilcorp": false,
        "evilcorp.malware": false
    }
}

Releasing

Releases are published automatically when a tag is pushed to GitHub.

# Create release variable.
$Release = "x.x.x"
# Create commit.
git commit --allow-empty -m "Release $Release"
# Create tag.
git tag -a $Release -m "Version $Release"
# Push from original.
git push origin --tags
# Push from fork.
git push upstream --tags

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvscodeextroh-0.0.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvscodeextroh-0.0.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file pyvscodeextroh-0.0.1.tar.gz.

File metadata

  • Download URL: pyvscodeextroh-0.0.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for pyvscodeextroh-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0b8c1524aebdd7727b7e2472990b2d86de93c373e91c757f4e555c5dedd7aea0
MD5 61d1d52c68c2d24a020914df2a7c07b1
BLAKE2b-256 70cd73df60c3872dceb0c2b82873ee8cdacdaa8da735c58921dc15eaa6647470

See more details on using hashes here.

File details

Details for the file pyvscodeextroh-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyvscodeextroh-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for pyvscodeextroh-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 63dd8a1d9d1022837d58ec58e7565f66096870ce9a0f78f18ed1e03d934df6b5
MD5 7df935a2e1572c241d91141a5f07fdc9
BLAKE2b-256 b908d71a4e42abee0b5bdfbe307bdc3f2cf55d7a06d118f0c347339b9a4f7c0c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page