Что делать если нужно поставить какую-то Python-библиотеку а root-прав нет? То есть в систему библиотеку никак и ничего не поставить.
Есть как минимум два способа это решить правильно!
🔸 Сделать виртуальное окружение и ставить там что угодно.
Это позволит создать полностью независимое исполняемое окружение для ваших приложений.
Все библиотеки будут храниться в домашней директории юзера а значит доступ на запись имеется.
Создать очень просто:
python3 -m venv ~/venvs/myenvname
Теперь активируем окружение
# Linux
source ~/venvs/myenvname/bin/activate
# Windows
%userprofile%\venvs\myenvname\Scripts\activate.bat
Можно ставить любые библиотеки и запускать приложение.
Это стандартный метод работы с любым проектом. Если еще не используете его, то пора начинать. Даже при наличии root доступа!
🔸 Бывает, что нет возможности запустить приложение из своего виртуального окружения. Например, его запускает какой-то сервис от вашего юзера и вставить активацию окружения вы не можете.
В этом случае можно установить библиотеки для Python не глобально в систему, а только для юзера.
Выполните этот код в консоли:
python3 -m site
Вы получите что-то такое:
sys.path = [
'/home/user',
'/usr/lib/python37.zip',
'/usr/lib/python3.7',
'/usr/lib/python3.7/lib-dynload',
'/home/user/.local/lib/python3.7/site-packages',
...
]
USER_BASE: '/home/user/.local'
USER_SITE: '/home/user/.local/lib/python3.7/site-packages'
ENABLE_USER_SITE: True
Нас интересует параметр USER_SITE. Это путь к пользовательским библиотекам, которые доступны по умолчанию, если они есть.
Именно сюда будут устанавливаться модули если добавить флаг --user при установке чего-либо через pip
pip install --user requests
Для этой команды не нужны root-права.
После неё можно запускать системный интерпретатор без виртуальных окружений и установленная библиотека будет доступна для текущего юзера.
Параметр USER_BASE показывает корневую директорию для хранения user-библиотек. Её можно изменить с помощью переменной окружения PYTHONUSERBASE
export PYTHONUSERBASE=~/pylibs
python3 -m site
...
USER_BASE: '/home/user/pylibs'
USER_SITE: '/home/user/pylibs/lib/python3.7/site-packages'
Получается некоторое подобие виртуального окружения для бедных 😁 которое можно менять через эту переменную (не делайте так!Лучше venv!)
🔸 Дописывание пути в PYTHONPATH
Этот способ не входит в список "двух правильных", но тоже рабочий. Здесь придётся сделать всё несколько сложней.
Сначала ставим библиотеку в любое место указывая путь установки
pip3 install -t ~/mylibs modulename
Библиотека установится без привязки к какому-либо интерпретатору. То есть по умолчанию не будет видна. Теперь в нужный момент добавляем этот путь в sys.path или в PYTHONPATH.
Не буду советовать так делать. Единственный раз когда этот способ мне пригодился и решил поставленную задачу, это при создании общей библиотеки для кластера компьютеров.
Модули лежат в сети и подгружаются для всех из одного и того же места. То есть обновлять файлы требуется только один раз а не на всех хосты отдельно.
Минусы такого подхода:
▫️Нужно всем хостам пробить нужный путь в .bashrc или ещё куда-то чтобы он сетапился на старте.
▫️Чем больше хостов тем больше нагрузка на сеть. Иногда такой способ не подходит именно по этой причине. Тогда Ansible вам в помощь.
▫️Не очень подходит если хосты с разными операционками. Некоторые библиотеки различаются для Linux и Windows (там, где есть бинарники) и приходится мудрить более сложные схемы.
#tricks#basic
NIST's Deepfake Playbook: Strategies for Managing Synthetic Content Risks
The U.S. National Institute of Standards and Technology (NIST) has released its report, "Reducing Risks Posed by Synthetic Content", addressing the challenges posed by AI-powered deepfakes. The document identifies three key approaches:
1️⃣ Tracking content provenance to verify its origins and edits.
2️⃣ Developing tools to label and identify AI-generated material.
3️⃣ Combatting AI-generated CSAM (Child Sexual Abuse Material) and NCII (Non-Consensual Intimate Imagery) involving real individuals.
The report highlights the broad scope of synthetic content risks, from personal harms like NCII to societal disinformation impacts. Cybersecurity and fraud risks are also underscored, as deepfake technologies can exploit biometric authentication or deceive individuals through voice cloning.
NIST emphasizes that the effectiveness of countermeasures depends on their purpose and audience. Techniques like provenance tracking can enhance transparency for general users, while specialized detection tools may better serve analysts and platforms in assessing and mitigating AI-generated content risks.
#Deepfakes#AIEthics#NIST
NIST Releases Tool for Testing AI Model Risks
The National Institute of Standards and Technology (NIST) has re-released Dioptra, a modular, open-source tool designed to assess and mitigate risks associated with AI models. Originally launched in 2022, Dioptra focuses on evaluating how malicious attacks, especially those that "poison" AI training data, can degrade an AI system's performance. This tool is crucial for companies training AI models and provides a common platform for simulating threats and conducting "red-teaming" exercises.
NIST's initiative, supported by President Joe Biden’s executive order on AI, aims to help government agencies, small to medium-sized businesses, and the broader community assess AI developers' claims and enhance AI safety standards. Dioptra's release aligns with global efforts, such as the U.K.'s AI Safety Institute’s Inspect tool, to advance AI model testing and ensure responsible AI development.
While Dioptra offers significant benefits, it currently works only with models that can be downloaded and used locally, excluding those gated behind APIs like OpenAI’s GPT-4. Despite this limitation, Dioptra represents a vital step towards understanding and mitigating AI risks, promoting a safer AI ecosystem.
#AI#AIDevelopment#AISafety#NIST#Cybersecurity
U.S. Congress Introduces Federal AI Risk Management Act 2024
Greetings everybody! U.S. Congress members have unveiled the Federal Artificial Intelligence Risk Management Act of 2024. Building upon the 2023 bill, this legislation mandates Federal Agencies to adopt the Artificial Intelligence Risk Management Framework (AI RMF) developed by the National Institute of Standards and Technology (NIST). Exceptions are made for national security systems.
NIST's AI RMF, shaped through an inclusive and open process with inputs from 240 organizations, becomes a cornerstone for agencies within a year of the bill's passage.
The Act also necessitates agencies to incorporate the framework into their AI risk management strategies within 180 days of NIST's guidelines. Furthermore, it empowers the Director of NIST and Administrator of Federal Procurement Policy to draft contract language mandating AI suppliers to adhere to the framework.
#AIRiskManagement#AIStandards#NIST#AIFramework
13 ноября NIST NVD наконец признали очевидное: им не удалось разобрать бэклог по анализу CVE до конца фискального года (30 сентября). Что, в общем-то, видно в их же статистике. На текущий момент в бэклоге 19860 идентификаторов. За эту неделю новых CVE поступило 1136, а проанализировали они только 510. И это не какая-то аномальная неделя, это сейчас норма. Они не справляются с разбором нового, чего уже говорить о бэклоге. Кризис продолжается.
При этом в сообщении они почему-то пишут, что у них полная команда аналитиков, и они обрабатывают все входящие CVE по мере их загрузки в систему. Но почему тогда их статистика показывает обратное?
Они пишут, что теперь обрабатывают все уязвимости из CISA KEV. И это хорошо. Но в CISA KEV за 2024 год добавили пока только 162 CVE. Круто, что они осилили эти идентификаторы, но достижение, мягко говоря, не впечатляет.
Почему NVD не справляются с бэклогом?
Они пишут, что дело в формате данных от Authorized Data Providers (ADPs), видимо имея в виду под этим CISA Vulnrichment. NVD не могут эффективно импортировать и улучшать данные в этом формате. Чтобы это делать они разрабатывают какие-то "новые системы".
То есть мало того, что они расписались в неспособности анализировать уязвимости самостоятельно и готовы использовать чужие данные as is, они ещё и не могут парсеры-конвертеры писать за адекватное время. 🐾 Просто удивительные. 🤦♂️
И тут ещё прошла новость, что сенатор Рэнд Пол, новый председатель Senate Homeland Security Committee пообещал серьезно сократить полномочия CISA или полностью их ликвидировать. Наш слоняра! 😁🐘 Весь движ там из-за работы CISA "по противодействию дезинформации" перед американскими выборами. Но под это дело могут угробить единственного американского ИБ-регулятора, который делает хоть что-то полезное и в адекватные сроки. Молодцы, так держать. 👍
Ничего кроме дальнейшей деградации ждать не приходится.
@avleonovrus#NIST#NVD#CISA#Vulnrichment#thoseamericans
NIST Launches Consortium to Shape US AI Policies
Hello, everyone! The National Institute of Standards and Technology (NIST) has initiated a consortium to address AI development and deployment challenges. The collaboration seeks to establish policies and measurements that prioritize human-centric AI safety and governance in the United States. The consortium will work on various aspects, including creating measurement and benchmarking tools, policy recommendations, red-teaming efforts, psychoanalysis, and environmental analysis.
This move comes in response to an executive order issued by US President Joseph Biden, which introduced six new standards for AI safety and security. While other regions have been more proactive in regulating AI systems, the US is catching up. The AI consortium represents a significant step in shaping the future of AI policies in the United States through collaboration between government bodies, non-profits, universities, and tech companies.
#NIST#AIConsortium#AIPolicies#USAIRegulation
NIST Issues Urgent Report on Escalating Threat of AI Attacks
Hello, dear subscribers! The National Institute of Standards and Technology (NIST) has released a critical report titled "Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations," sounding the alarm on the intensifying threat landscape targeting artificial intelligence systems. In the face of increasingly powerful yet vulnerable AI systems, the report outlines the technique of adversarial machine learning, wherein attackers manipulate AI systems through subtle tactics with potentially catastrophic consequences.
The document categorizes these attacks based on attackers' goals, capabilities, and knowledge of the target AI system. Concerns include "data poisoning" and "backdoor attacks," exploiting vulnerabilities in AI system development and deployment.
#NIST#AIAttacks#AISecurity#ThreatLandscape#MachineLearning**