id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
24,900 | power_management_linux.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/power_management_linux.py | import asyncio
from middlewared.service import private, Service
from middlewared.utils import run
class DiskService(Service):
@private
async def power_management_impl(self, dev, disk):
self.middleware.create_task(run(
'hdparm', '-B', disk['advpowermgmt'] if disk['advpowermgmt'] != 'DISAB... | 1,171 | Python | .py | 25 | 36.44 | 113 | 0.597893 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,901 | disk_events.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/disk_events.py | from middlewared.utils.disks import DISKS_TO_IGNORE
async def added_disk(middleware, disk_name):
await middleware.call('disk.sync', disk_name)
await middleware.call('disk.sed_unlock', disk_name)
await middleware.call('alert.oneshot_delete', 'SMART', disk_name)
async def remove_disk(middleware, disk_name... | 961 | Python | .py | 21 | 40.333333 | 69 | 0.694952 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,902 | wipe.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/wipe.py | import asyncio
import os
import pathlib
import threading
import time
from middlewared.schema import accepts, Bool, Ref, Str, returns
from middlewared.service import job, Service, private
CHUNK = 1048576 # 1MB binary
# Maximum number of attempts to request partition table update
MAX_NUM_PARTITION_UPDATE_RETRIES = 4
... | 8,198 | Python | .py | 170 | 33.647059 | 118 | 0.53385 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,903 | temperature.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/temperature.py | import asyncio
import datetime
import time
import json
import async_timeout
from middlewared.api import api_method
from middlewared.api.current import DiskTemperatureAlertsArgs, DiskTemperatureAlertsResult
from middlewared.common.smart.smartctl import SMARTCTL_POWERMODES
from middlewared.schema import accepts, Bool, ... | 6,254 | Python | .py | 140 | 34.2 | 134 | 0.599573 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,904 | sync.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/sync.py | import re
from datetime import timedelta
from middlewared.schema import accepts, Bool, Dict, Str
from middlewared.service import job, private, Service, ServiceChangeMixin
from middlewared.utils.disks import dev_to_ident
from middlewared.utils.time_utils import utc_now
RE_IDENT = re.compile(r'^\{(?P<type>.+?)\}(?P<va... | 13,677 | Python | .py | 267 | 38.902622 | 119 | 0.582778 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,905 | retaste.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/retaste.py | import fcntl
import logging
import multiprocessing
import os
import re
from middlewared.schema import List, Str
from middlewared.service import Service, accepts, job, private
logger = logging.getLogger(__name__)
SD_PATTERN = re.compile(r"^sd[a-z]+$")
NVME_PATTERN = re.compile(r"^nvme\d+n\d+$")
def taste_it(disk, ... | 2,636 | Python | .py | 67 | 31.492537 | 93 | 0.621176 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,906 | smartctl.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/smartctl.py | import asyncio
import subprocess
from middlewared.common.smart.smartctl import get_smartctl_args, smartctl, SMARTCTX
from middlewared.schema import accepts, Bool, Dict, List, Str
from middlewared.service import CallError, private, Service
from middlewared.utils.asyncio_ import asyncio_map
class DiskService(Service):... | 3,363 | Python | .py | 70 | 35.9 | 109 | 0.597498 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,907 | format.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/format.py | import pathlib
import parted
from middlewared.service import CallError, private, Service
class DiskService(Service):
@private
def format(self, disk):
"""Format a data drive with a maximized data partition"""
sysfs = pathlib.Path(f'/sys/class/block/{disk}')
if not sysfs.exists():
... | 3,347 | Python | .py | 54 | 50.814815 | 112 | 0.638246 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,908 | zfs_guid.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/zfs_guid.py | import bidict
from middlewared.service import private, Service
from middlewared.service_exception import MatchNotFound
class DiskService(Service):
@private
async def disk_by_zfs_guid(self, guid):
"""
This method returns a single disk entry with the specified
ZFS guid. The database how... | 5,137 | Python | .py | 108 | 34.518519 | 115 | 0.549521 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,909 | sed.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/sed.py | import re
from middlewared.service import Service, private
from middlewared.utils import run
RE_HDPARM_DRIVE_LOCKED = re.compile(r'Security.*\n\s*locked', re.DOTALL)
class DiskService(Service):
@private
async def unlock_ata_security(self, devname, _adv, password):
locked = unlocked = False
... | 840 | Python | .py | 20 | 33.2 | 114 | 0.62069 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,910 | availability.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/availability.py | from collections import defaultdict
from middlewared.service import accepts, private, Service
from middlewared.service_exception import ValidationErrors
from middlewared.schema import Bool, Dict, Str
from middlewared.utils.disks import dev_to_ident
class DiskService(Service):
@private
async def get_exported... | 8,588 | Python | .py | 166 | 39.789157 | 116 | 0.586433 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,911 | identify.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/identify.py | import re
from middlewared.schema import accepts, Dict, Str
from middlewared.service import Service, private
from middlewared.utils.disks import get_disks_with_identifiers
class DiskService(Service):
RE_IDENTIFIER = re.compile(r'^\{(?P<type>.+?)\}(?P<value>.+)$')
@private
@accepts(Str('name'), Dict('di... | 2,106 | Python | .py | 48 | 34.3125 | 112 | 0.602245 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,912 | smart.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/smart.py | from middlewared.service import private, Service
class DiskService(Service):
@private
async def toggle_smart_off(self, name):
await self.middleware.call('disk.smartctl', name, ['--smart=off'], {'silent': True})
@private
async def toggle_smart_on(self, name):
await self.middleware.call... | 378 | Python | .py | 8 | 41.875 | 92 | 0.683924 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,913 | info.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/info.py | from middlewared.schema import accepts, Str
from middlewared.service import filterable, private, Service
from middlewared.utils import filter_list
class DiskService(Service):
@private
@filterable
async def list_all_partitions(self, filters, options):
"""
Returns list of all partitions pre... | 1,454 | Python | .py | 35 | 33.742857 | 114 | 0.660297 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,914 | smart_attributes.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/smart_attributes.py | import json
import re
from middlewared.schema import Bool, Dict, Int, List, returns, Str
from middlewared.service import accepts, CallError, private, Service
RE_SATA_DOM_LIFETIME = re.compile(r'^164\s+.*\s+([0-9]+)$', re.M)
class DiskService(Service):
@accepts(Str('name'))
@returns(List('smart_attributes', ... | 2,259 | Python | .py | 53 | 33.471698 | 139 | 0.595086 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,915 | resize.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/resize.py | import os
import asyncio
import subprocess
from middlewared.utils import run, UnexpectedFailure
from middlewared.service import Service, CallError, private, accepts, returns, job, ValidationErrors
from middlewared.schema import Dict, Str, Int, List, Bool
class DiskService(Service):
@private
async def resize... | 3,239 | Python | .py | 79 | 30.291139 | 109 | 0.566847 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,916 | disk_info.py | truenas_middleware/src/middlewared/middlewared/plugins/disk_/disk_info.py | import collections
import contextlib
import glob
import os
import pathlib
import pyudev
from middlewared.service import CallError, private, Service
# The basic unit of a block I/O is a sector. A sector is
# 512 (2 ** 9) bytes. In sysfs, the files (sector_t type)
# `<disk>/<part>/start` and `<disk>/<part>/size` are
... | 6,866 | Python | .py | 165 | 32.921212 | 111 | 0.61241 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,917 | gmail.py | truenas_middleware/src/middlewared/middlewared/plugins/mail_/gmail.py | import base64
from threading import Lock
import googleapiclient
from googleapiclient.discovery import build
from google.oauth2.credentials import Credentials
import google_auth_httplib2
import httplib2
from middlewared.service import private, Service
class GmailService:
def __init__(self, config):
self.... | 3,326 | Python | .py | 75 | 33.826667 | 104 | 0.62651 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,918 | kernel.py | truenas_middleware/src/middlewared/middlewared/plugins/dlm_/kernel.py | import binascii
import contextlib
import ctypes
import glob
import ipaddress
import os
import os.path
import pathlib
import socket
import subprocess
from middlewared.service import Service
class sockaddr_in(ctypes.Structure):
_fields_ = [('sa_family', ctypes.c_ushort), # sin_family
('sin_port', ... | 8,728 | Python | .py | 181 | 38.320442 | 120 | 0.636866 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,919 | sync.py | truenas_middleware/src/middlewared/middlewared/plugins/kmip/sync.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
from middlewared.schema import Bool, returns
from middlewared.service import accepts, CallError, job, periodic, private, Service
from .connection import... | 4,758 | Python | .py | 103 | 36.786408 | 116 | 0.626589 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,920 | zfs_keys.py | truenas_middleware/src/middlewared/middlewared/plugins/kmip/zfs_keys.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
from middlewared.service import job, private, Service
from .connection import KMIPServerMixin
class KMIPService(Service, KMIPServerMixin):
def __... | 8,127 | Python | .py | 156 | 38.589744 | 119 | 0.566114 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,921 | utils.py | truenas_middleware/src/middlewared/middlewared/plugins/kmip/utils.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
SUPPORTED_SSL_VERSIONS = ['PROTOCOL_TLSv1', 'PROTOCOL_TLSv1_1', 'PROTOCOL_TLSv1_2']
| 251 | Python | .py | 5 | 49 | 83 | 0.77551 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,922 | __init__.py | truenas_middleware/src/middlewared/middlewared/plugins/kmip/__init__.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
async def initialize_kmip_keys(middleware):
if (await middleware.call('kmip.config'))['enabled']:
await middleware.call('kmip.initialize_keys... | 702 | Python | .py | 14 | 46.214286 | 78 | 0.75549 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,923 | attachment.py | truenas_middleware/src/middlewared/middlewared/plugins/kmip/attachment.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
from middlewared.common.attachment.certificate import CertificateServiceAttachmentDelegate
from middlewared.common.ports import ServicePortDelegate
cla... | 859 | Python | .py | 18 | 44.222222 | 108 | 0.80649 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,924 | sed_keys.py | truenas_middleware/src/middlewared/middlewared/plugins/kmip/sed_keys.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
from middlewared.service import job, private, Service
from .connection import KMIPServerMixin
'''
SED keys are stored in 2 places:
1) system.advanced ... | 18,274 | Python | .py | 344 | 40.648256 | 117 | 0.597999 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,925 | connection.py | truenas_middleware/src/middlewared/middlewared/plugins/kmip/connection.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
import contextlib
import socket
import uuid
from kmip.core import enums
from kmip.pie.client import ProxyKmipClient
from kmip.pie.exceptions import Clie... | 3,763 | Python | .py | 93 | 30.376344 | 117 | 0.601313 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,926 | update.py | truenas_middleware/src/middlewared/middlewared/plugins/kmip/update.py | # Copyright (c) - iXsystems Inc.
#
# Licensed under the terms of the TrueNAS Enterprise License Agreement
# See the file LICENSE.IX for complete terms and conditions
import middlewared.sqlalchemy as sa
from middlewared.async_validators import validate_port
from middlewared.schema import Bool, Dict, Int, Patch, Str
fr... | 9,492 | Python | .py | 167 | 46.161677 | 118 | 0.634984 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,927 | client.py | truenas_middleware/src/middlewared/middlewared/plugins/ntp_/client.py | import dataclasses
import socket
import struct
import time
def format_ntp_packet(data):
# unpack the response
unpacked = struct.unpack('!B B B b 11I', data)
recv_timestamp = unpacked[11] + float(unpacked[12]) / 2 ** 32
ntp_time = recv_timestamp - 2208988800 # NTP timestamp starts from 1st January 19... | 1,612 | Python | .py | 40 | 32.675 | 88 | 0.596289 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,928 | enums.py | truenas_middleware/src/middlewared/middlewared/plugins/ntp_/enums.py | import enum
class Mode(enum.Enum):
SERVER = 'SERVER'
PEER = 'PEER'
LOCAL = 'LOCAL'
@staticmethod
def from_str(strval):
if strval in ('SERVER', '^'):
return Mode.SERVER
elif strval in ('PEER', '='):
return Mode.PEER
elif strval in ('LOCAL', '#'):
... | 1,587 | Python | .py | 49 | 24.163265 | 65 | 0.575262 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,929 | util.py | truenas_middleware/src/middlewared/middlewared/plugins/datastore/util.py | from middlewared.schema import accepts
from middlewared.service import CallError, private, Service
from middlewared.sqlalchemy import Model
from .schema import SchemaMixin
class DatastoreService(Service, SchemaMixin):
class Config:
private = True
@private
async def get_backrefs(self, name):
... | 2,511 | Python | .py | 61 | 27.393443 | 115 | 0.520295 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,930 | event.py | truenas_middleware/src/middlewared/middlewared/plugins/datastore/event.py | from collections import defaultdict
from middlewared.schema import accepts, Dict, Str
from middlewared.service import Service
class DatastoreService(Service):
class Config:
private = True
events = defaultdict(list)
@accepts(Dict(
"options",
Str("description", required=True),
... | 2,673 | Python | .py | 65 | 30.461538 | 118 | 0.575617 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,931 | filter.py | truenas_middleware/src/middlewared/middlewared/plugins/datastore/filter.py | import operator
from .schema import SchemaMixin
def in_(col, value):
has_nulls = None in value
value = [v for v in value if v is not None]
expr = col.in_(value)
if has_nulls:
expr = expr | (col == None) # noqa
return expr
def nin(col, value):
has_nulls = None in value
value = [... | 2,323 | Python | .py | 61 | 25.098361 | 114 | 0.468681 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,932 | write.py | truenas_middleware/src/middlewared/middlewared/plugins/datastore/write.py | from sqlalchemy import and_, types
from sqlalchemy.sql import sqltypes
from middlewared.schema import accepts, Any, Bool, Dict, Str
from middlewared.service import Service
from .filter import FilterMixin
from .schema import SchemaMixin
"""
By default, when an update/insert/delete operation occurs we will
emit an ev... | 7,301 | Python | .py | 169 | 32.863905 | 117 | 0.59876 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,933 | read.py | truenas_middleware/src/middlewared/middlewared/plugins/datastore/read.py | from collections import defaultdict
import re
from sqlalchemy import and_, func, select
from sqlalchemy.sql import Alias
from sqlalchemy.sql.elements import UnaryExpression
from sqlalchemy.sql.expression import nullsfirst, nullslast
from sqlalchemy.sql.operators import desc_op, nullsfirst_op, nullslast_op
from middle... | 10,722 | Python | .py | 229 | 34.375546 | 113 | 0.565509 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,934 | connection.py | truenas_middleware/src/middlewared/middlewared/plugins/datastore/connection.py | from concurrent.futures import ThreadPoolExecutor
import re
import shutil
import time
from sqlalchemy import create_engine
from middlewared.service import private, Service
from middlewared.plugins.config import FREENAS_DATABASE
thread_pool = ThreadPoolExecutor(1)
def regexp(expr, item):
if item is None:
... | 4,240 | Python | .py | 89 | 38.101124 | 123 | 0.657441 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,935 | schema.py | truenas_middleware/src/middlewared/middlewared/plugins/datastore/schema.py | from sqlalchemy import inspect
from middlewared.sqlalchemy import Model
class SchemaMixin:
def _get_table(self, name):
return Model.metadata.tables[name.replace('.', '_').lower()]
def _get_pk(self, table):
return [col for col in table.c if col.primary_key][0]
def _get_col(self, table, n... | 1,168 | Python | .py | 28 | 32.321429 | 85 | 0.60496 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,936 | enums.py | truenas_middleware/src/middlewared/middlewared/plugins/truecommand/enums.py | import enum
class Status(enum.Enum):
CONNECTED = 'CONNECTED'
CONNECTING = 'CONNECTING'
DISABLED = 'DISABLED'
FAILED = 'FAILED'
# In the database we save 3 states, CONNECTED/DISABLED/FAILED
# Connected is saved when portal has approved an api key
# Disabled is saved when TC service is disabled
# Faile... | 1,132 | Python | .py | 27 | 38.888889 | 79 | 0.758652 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,937 | wireguard.py | truenas_middleware/src/middlewared/middlewared/plugins/truecommand/wireguard.py | import asyncio
import re
import time
from middlewared.schema import Bool, Dict, IPAddr, returns, Str
from middlewared.service import accepts, CallError, periodic, private, Service
from middlewared.utils import run
from .enums import Status
from .utils import WIREGUARD_INTERFACE_NAME
HEALTH_CHECK_SECONDS = 1800
WIREG... | 7,084 | Python | .py | 130 | 42.769231 | 119 | 0.620317 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,938 | __init__.py | truenas_middleware/src/middlewared/middlewared/plugins/truecommand/__init__.py | from .enums import Status
async def _event_system_ready(middleware, event_type, args):
if await middleware.call('failover.licensed'):
return
await middleware.call('truecommand.start_truecommand_service')
async def setup(middleware):
await middleware.call('truecommand.config')
middleware.eve... | 965 | Python | .py | 20 | 41.85 | 103 | 0.723586 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,939 | portal.py | truenas_middleware/src/middlewared/middlewared/plugins/truecommand/portal.py | import asyncio
from middlewared.service import CallError, job, private, Service
from .connection import TruecommandAPIMixin
from .enums import PortalResponseState, Status
class TruecommandService(Service, TruecommandAPIMixin):
POLLING_GAP_MINUTES = 5
@private
@job(lock='poll_ix_portal_api_truecommand'... | 8,391 | Python | .py | 156 | 38.269231 | 116 | 0.558369 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,940 | connection.py | truenas_middleware/src/middlewared/middlewared/plugins/truecommand/connection.py | import aiohttp
import async_timeout
import asyncio
import json
class TruecommandAPIMixin:
PORTAL_URI = 'https://portal.ixsystems.com/api'
async def _post_call(self, options=None, payload=None):
if not await self.middleware.call('network.general.can_perform_activity', 'truecommand'):
retu... | 1,421 | Python | .py | 31 | 34.677419 | 102 | 0.605206 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,941 | update.py | truenas_middleware/src/middlewared/middlewared/plugins/truecommand/update.py | import asyncio
import middlewared.sqlalchemy as sa
from middlewared.schema import Bool, Dict, Int, IPAddr, Password, Str
from middlewared.service import accepts, ConfigService, private, ValidationErrors
from middlewared.validators import Range
from .enums import Status, StatusReason
CONNECTING_STATUS_REASON = 'Wai... | 10,785 | Python | .py | 192 | 44.546875 | 119 | 0.623851 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,942 | crud.py | truenas_middleware/src/middlewared/middlewared/plugins/replication_/crud.py | from middlewared.schema import accepts, Dataset, Dict, Int, Str
from middlewared.service import item_method, pass_app, Service
class ReplicationService(Service):
@item_method
@accepts(
Int("id"),
Dict(
"replication_restore",
Str("name", required=True),
Data... | 2,513 | Python | .py | 51 | 36.882353 | 118 | 0.569099 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,943 | config.py | truenas_middleware/src/middlewared/middlewared/plugins/replication_/config.py | from middlewared.schema import accepts, Dict, Int
from middlewared.service import ConfigService
import middlewared.sqlalchemy as sa
from middlewared.validators import Range
class ReplicationConfigModel(sa.Model):
__tablename__ = "storage_replication_config"
id = sa.Column(sa.Integer(), primary_key=True)
... | 1,550 | Python | .py | 41 | 29.317073 | 107 | 0.639519 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,944 | cert_attachments.py | truenas_middleware/src/middlewared/middlewared/plugins/ldap_/cert_attachments.py | from middlewared.common.attachment.certificate import CertificateServiceAttachmentDelegate
class LdapCertificateAttachmentDelegate(CertificateServiceAttachmentDelegate):
HUMAN_NAME = 'LDAP Service'
SERVICE = 'ldap'
SERVICE_VERB = 'start'
async def setup(middleware):
await middleware.call('certifica... | 401 | Python | .py | 7 | 53.285714 | 116 | 0.840617 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,945 | ldap_client.py | truenas_middleware/src/middlewared/middlewared/plugins/ldap_/ldap_client.py | import copy
import threading
import ldap as pyldap
from ldap.controls import SimplePagedResultsControl
from middlewared.plugins.directoryservices import SSL
client_lock = threading.RLock()
def ldap_client_lock(fn):
def inner(*args, **kwargs):
with client_lock:
return fn(*args, **kwargs)
... | 6,355 | Python | .py | 178 | 22.949438 | 100 | 0.521604 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,946 | constants.py | truenas_middleware/src/middlewared/middlewared/plugins/ldap_/constants.py | from middlewared.schema import Dict, Str, LDAP_DN
# Different server_types that we can auto-detect
SERVER_TYPE_ACTIVE_DIRECTORY = 'ACTIVE_DIRECTORY'
SERVER_TYPE_FREEIPA = 'FREEIPA'
SERVER_TYPE_GENERIC = 'GENERIC'
SERVER_TYPE_OPENLDAP = 'OPENLDAP'
# keys for search_bases in our LDAP plugin schema
SEARCH_BASE_USER = '... | 4,136 | Python | .py | 132 | 28.234848 | 73 | 0.728597 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,947 | utils.py | truenas_middleware/src/middlewared/middlewared/plugins/ldap_/utils.py | from . import constants
def search_base_data_to_params(data):
"""
This method converts the data from our schema key `search_bases` into
nslcd configuration information
"""
search_params = []
for base in constants.LDAP_SEARCH_BASE_KEYS:
if not (value := data.get(base)):
cont... | 4,030 | Python | .py | 79 | 36.151899 | 97 | 0.565736 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,948 | cert_attachments.py | truenas_middleware/src/middlewared/middlewared/plugins/idmap_/cert_attachments.py | from middlewared.common.attachment.certificate import CertificateCRUDServiceAttachmentDelegate
class IdmapCertificateAttachmentDelegate(CertificateCRUDServiceAttachmentDelegate):
CERT_FILTER_KEY = 'certificate.id'
HUMAN_NAME = 'IDMAP Service'
NAMESPACE = 'idmap'
async def redeploy(self, cert_id):
... | 480 | Python | .py | 9 | 48.555556 | 117 | 0.819355 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,949 | idmap_constants.py | truenas_middleware/src/middlewared/middlewared/plugins/idmap_/idmap_constants.py | import enum
import wbclient
# Base datastore `id` value for entries that are returned as user.query and
# group.query results. We add the posix uid / gid to this number to ensure
# that it is unique at a given point in time.
BASE_SYNTHETIC_DATASTORE_ID = 100000000
TRUENAS_IDMAP_MAX = 2147000000 # Maximum ID that we ... | 983 | Python | .py | 28 | 30.178571 | 84 | 0.678609 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,950 | gencache.py | truenas_middleware/src/middlewared/middlewared/plugins/idmap_/gencache.py | import enum
import wbclient
from middlewared.service import Service
from middlewared.service_exception import MatchNotFound
from middlewared.utils import filter_list
from middlewared.utils.tdb import (
get_tdb_handle,
TDBDataType,
TDBError,
TDBOptions,
TDBPathType,
)
GENCACHE_FILE = '/var/run/samb... | 3,811 | Python | .py | 95 | 31.294737 | 80 | 0.632692 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,951 | idmap_winbind.py | truenas_middleware/src/middlewared/middlewared/plugins/idmap_/idmap_winbind.py | import errno
import wbclient
from .idmap_constants import IDType, MAX_REQUEST_LENGTH
from middlewared.utils.itertools import batched
from middlewared.service_exception import MatchNotFound
WBCErr = {
wbclient.WBC_ERR_SUCCESS: None,
wbclient.WBC_ERR_NOT_IMPLEMENTED: errno.ENOSYS,
wbclient.WBC_ERR_UNKNOWN_... | 5,645 | Python | .py | 146 | 29.520548 | 90 | 0.594471 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,952 | idmap_sss.py | truenas_middleware/src/middlewared/middlewared/plugins/idmap_/idmap_sss.py | import pysss_nss_idmap as sssclient
from .idmap_constants import IDType
from middlewared.service_exception import MatchNotFound
class SSSClient:
def _username_to_entry(self, username):
"""
Sample entry returned by pysss_nss_idmap
`getsidbyusername`
{'smbuser': {'sid': 'S-1-5-21-... | 6,668 | Python | .py | 178 | 26.320225 | 108 | 0.516835 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,953 | backend.py | truenas_middleware/src/middlewared/middlewared/plugins/audit/backend.py | import os
import threading
import time
from sqlalchemy import create_engine, inspect
from sqlalchemy import and_, func, select
from sqlalchemy.exc import DBAPIError
from sqlalchemy.orm import Session
from sqlalchemy.sql.expression import nullsfirst, nullslast
from middlewared.schema import accepts, Ref, Str
from midd... | 8,931 | Python | .py | 213 | 30.131455 | 104 | 0.574856 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,954 | utils.py | truenas_middleware/src/middlewared/middlewared/plugins/audit/utils.py | import middlewared.sqlalchemy as sa
import os
from sqlalchemy import Table
from sqlalchemy.orm import declarative_base
from .schema.common import AuditEventParam
AUDIT_DATASET_PATH = '/audit'
AUDITED_SERVICES = [('MIDDLEWARE', 0.1), ('SMB', 0.1), ('SUDO', 0.1)]
AUDIT_TABLE_PREFIX = 'audit_'
AUDIT_LIFETIME = 7
AUDIT_D... | 6,370 | Python | .py | 157 | 32.808917 | 95 | 0.651061 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,955 | __init__.py | truenas_middleware/src/middlewared/middlewared/plugins/audit/__init__.py | async def setup(middleware):
try:
# Set up connections to the auditing databases
await middleware.call("auditbackend.setup")
except Exception:
middleware.logger.error("Failed to set up auditing backend.", exc_info=True)
if await middleware.call("keyvalue.get", "run_migration", False)... | 625 | Python | .py | 13 | 40 | 97 | 0.686275 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,956 | audit.py | truenas_middleware/src/middlewared/middlewared/plugins/audit/audit.py | import asyncio
import csv
import errno
import json
import middlewared.sqlalchemy as sa
import os
import shutil
import time
import uuid
import yaml
from truenas_api_client import json as ejson
from .utils import (
AUDIT_DATASET_PATH,
AUDIT_LIFETIME,
AUDIT_DEFAULT_RESERVATION,
AUDIT_DEFAULT_QUOTA,
A... | 23,400 | Python | .py | 510 | 35.217647 | 144 | 0.603571 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,957 | sudo.py | truenas_middleware/src/middlewared/middlewared/plugins/audit/schema/sudo.py | from middlewared.schema import (
Bool,
Dict,
Int,
IPAddr,
Str,
UUID,
)
from .common import (
AuditEnum,
AuditEventParam,
AuditSchema,
AUDIT_VERS,
audit_schema_from_base,
convert_schema_to_set,
)
class AuditSudoEventType(AuditEnum):
ACCEPT = 'ACCEPT'
REJECT = 'RE... | 1,617 | Python | .py | 55 | 25.454545 | 81 | 0.736399 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,958 | smb.py | truenas_middleware/src/middlewared/middlewared/plugins/audit/schema/smb.py | from .common import (
AuditEnum,
AuditEventParam,
AuditSchema,
AUDIT_VERS,
AUDIT_RESULT_NTSTATUS,
AUDIT_RESULT_UNIX,
AuditFileType,
AUDIT_FILE,
AUDIT_FILE_HANDLE,
audit_schema_from_base,
AUDIT_UNIX_TOKEN,
convert_schema_to_set
)
from middlewared.schema import (
Bool,
... | 9,950 | Python | .py | 341 | 24.442815 | 83 | 0.691323 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,959 | middleware.py | truenas_middleware/src/middlewared/middlewared/plugins/audit/schema/middleware.py | from middlewared.schema import (
Bool,
Dict,
Int,
IPAddr,
List,
Str,
UUID,
)
from .common import (
AuditEnum,
AuditEventParam,
AuditSchema,
AUDIT_VERS,
audit_schema_from_base,
convert_schema_to_set,
)
class AuditMiddlewareEventType(AuditEnum):
AUTHENTICATION = '... | 2,329 | Python | .py | 73 | 27.219178 | 93 | 0.721626 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,960 | common.py | truenas_middleware/src/middlewared/middlewared/plugins/audit/schema/common.py | import enum
from copy import deepcopy
from middlewared.schema import (
Dict,
Int,
List,
Str,
)
class AuditEnum(enum.Enum):
def __str__(self):
return str(self.value)
class AuditSchema(Dict):
def extend(self, *attrs, **kwargs):
for i in attrs:
self.attrs[i.name] = ... | 3,681 | Python | .py | 118 | 23.211864 | 105 | 0.578112 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,961 | challenge.py | truenas_middleware/src/middlewared/middlewared/plugins/acme_protocol_/challenge.py | import josepy as jose
import json
from acme import messages
from middlewared.schema import accepts, Dict, Int, Str
from middlewared.service import private, Service
from .authenticators.factory import auth_factory
class DNSAuthenticatorService(Service):
class Config:
namespace = 'acme.dns.authenticator... | 1,827 | Python | .py | 41 | 37.146341 | 110 | 0.695775 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,962 | acme_svc.py | truenas_middleware/src/middlewared/middlewared/plugins/acme_protocol_/acme_svc.py | import josepy as jose
import json
from acme import client, messages
from middlewared.service import Service
class ACMEService(Service):
class Config:
namespace = 'acme'
private = True
def get_acme_client_and_key(self, acme_directory_uri, tos=False):
data = self.middleware.call_sync... | 1,636 | Python | .py | 43 | 26.372093 | 109 | 0.522699 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,963 | issue_cert.py | truenas_middleware/src/middlewared/middlewared/plugins/acme_protocol_/issue_cert.py | import copy
import datetime
import errno
from acme import errors, messages
from middlewared.service import Service, ValidationErrors
from middlewared.service_exception import CallError
class ACMEService(Service):
class Config:
namespace = 'acme'
private = True
def issue_certificate(self, j... | 8,347 | Python | .py | 154 | 39.642857 | 130 | 0.582446 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,964 | schema.py | truenas_middleware/src/middlewared/middlewared/plugins/acme_protocol_/schema.py | from middlewared.api import api_method
from middlewared.api.current import DNSAuthenticatorSchemasArgs, DNSAuthenticatorSchemasResult
from middlewared.service import private, Service
from .authenticators.factory import auth_factory
class DNSAuthenticatorService(Service):
class Config:
namespace = 'acme.... | 1,166 | Python | .py | 23 | 43.826087 | 109 | 0.71743 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,965 | factory.py | truenas_middleware/src/middlewared/middlewared/plugins/acme_protocol_/authenticators/factory.py | import errno
from middlewared.service_exception import CallError
from .cloudflare import CloudFlareAuthenticator
from .ovh import OVHAuthenticator
from .route53 import Route53Authenticator
from .shell import ShellAuthenticator
class AuthenticatorFactory:
def __init__(self):
self._creators = {}
def... | 888 | Python | .py | 25 | 30.6 | 92 | 0.760844 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,966 | cloudflare.py | truenas_middleware/src/middlewared/middlewared/plugins/acme_protocol_/authenticators/cloudflare.py | import logging
from certbot_dns_cloudflare._internal.dns_cloudflare import _CloudflareClient
from middlewared.schema import accepts, Dict, Password, Str, ValidationErrors
from middlewared.service import skip_arg
from .base import Authenticator
logger = logging.getLogger(__name__)
class CloudFlareAuthenticator(Au... | 2,531 | Python | .py | 50 | 41.56 | 119 | 0.663828 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,967 | route53.py | truenas_middleware/src/middlewared/middlewared/plugins/acme_protocol_/authenticators/route53.py | import errno
import boto3
import time
from botocore import exceptions as boto_exceptions
from middlewared.schema import accepts, Dict, Password, Str
from middlewared.service import CallError, skip_arg
from .base import Authenticator
class Route53Authenticator(Authenticator):
NAME = 'route53'
SCHEMA = Dic... | 4,364 | Python | .py | 90 | 36.222222 | 105 | 0.586701 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,968 | ovh.py | truenas_middleware/src/middlewared/middlewared/plugins/acme_protocol_/authenticators/ovh.py | import logging
from lexicon.providers.ovh import ENDPOINTS
from certbot_dns_ovh._internal.dns_ovh import _OVHLexiconClient
from middlewared.schema import accepts, Dict, Password, Str
from middlewared.service import skip_arg
from .base import Authenticator
logger = logging.getLogger(__name__)
OVH_ENDPOINTS = tuple(... | 1,820 | Python | .py | 37 | 42.864865 | 112 | 0.716949 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,969 | base.py | truenas_middleware/src/middlewared/middlewared/plugins/acme_protocol_/authenticators/base.py | import time
from middlewared.service import CallError
class Authenticator:
NAME = NotImplementedError
PROPAGATION_DELAY = NotImplementedError
SCHEMA = NotImplementedError
def __init__(self, middleware, attributes):
self.middleware = middleware
self.attributes = attributes
se... | 1,471 | Python | .py | 33 | 36.787879 | 98 | 0.703366 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,970 | shell.py | truenas_middleware/src/middlewared/middlewared/plugins/acme_protocol_/authenticators/shell.py | """
The authenticator script is called two times during the certificate generation:
1. The validation record creation which is called in the following way:
script set domain validation_name validaton_context timeout
2. The validation record deletion which is called in following way:
script unset domain validatio... | 3,061 | Python | .py | 65 | 39.523077 | 107 | 0.678416 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,971 | event_source.py | truenas_middleware/src/middlewared/middlewared/plugins/smart_/event_source.py | import asyncio
import time
from middlewared.event import EventSource
from middlewared.service import private, Service
from middlewared.service_exception import MatchNotFound
class SMARTTestService(Service):
class Config:
namespace = 'smart.test'
cli_namespace = 'task.smart_test'
tests = {}
... | 2,237 | Python | .py | 55 | 29.563636 | 103 | 0.583719 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,972 | schedule.py | truenas_middleware/src/middlewared/middlewared/plugins/smart_/schedule.py | # -*- coding=utf-8 -*-
from collections import namedtuple
import re
__all__ = ["smartd_schedule_piece", "smartd_schedule_piece_values"]
ALL_VALUES = object()
RE_RANGE_WITH_DIVISOR = re.compile(r"((?P<min>[0-9]+)-(?P<max>[0-9]+)|\*)/(?P<divisor>[0-9]+)")
RE_RANGE = re.compile(r"((?P<min>[0-9]+)-(?P<max>[0-9]+)|\*)")
... | 2,509 | Python | .py | 60 | 34.35 | 96 | 0.543326 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,973 | ports.py | truenas_middleware/src/middlewared/middlewared/plugins/ports/ports.py | import ipaddress
import itertools
from collections import defaultdict
from middlewared.service import Service, ValidationErrors
from .utils import WILDCARD_IPS
SYSTEM_PORTS = [(wildcard, port) for wildcard in WILDCARD_IPS for port in [67, 123, 3702, 5353, 6000]]
def get_ip_version(ip: str) -> int:
return ipa... | 4,065 | Python | .py | 90 | 33.655556 | 115 | 0.58116 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,974 | __init__.py | truenas_middleware/src/middlewared/middlewared/plugins/rate_limit/__init__.py | from middlewared.service import periodic, Service
from middlewared.utils.rate_limit.cache import RateLimitCache
CLEAR_CACHE_INTERVAL = 600
class RateLimitService(Service):
class Config:
namespace = 'rate.limit'
private = True
cli_private = True
@periodic(interval=CLEAR_CACHE_INTERVA... | 1,232 | Python | .py | 25 | 42.08 | 67 | 0.694167 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,975 | 2fa.py | truenas_middleware/src/middlewared/middlewared/plugins/auth_/2fa.py | import base64
import contextlib
import pyotp
import middlewared.sqlalchemy as sa
from middlewared.schema import accepts, Bool, Dict, Int, Patch
from middlewared.service import CallError, ConfigService, periodic, private
from middlewared.utils.directoryservices.constants import DSStatus, DSType
from middlewared.valida... | 5,639 | Python | .py | 139 | 30.517986 | 116 | 0.580073 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,976 | authenticate.py | truenas_middleware/src/middlewared/middlewared/plugins/auth_/authenticate.py | import os
import pam
from middlewared.auth import AuthenticationContext
from middlewared.plugins.account import unixhash_is_valid
from middlewared.plugins.account_.constants import (
ADMIN_UID, MIDDLEWARE_PAM_SERVICE, MIDDLEWARE_PAM_API_KEY_SERVICE
)
from middlewared.service import Service, pass_app, private
from ... | 9,268 | Python | .py | 183 | 38.743169 | 126 | 0.599978 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,977 | cert_info.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/cert_info.py | from middlewared.schema import accepts, Dict, Ref, returns, Str
from middlewared.service import private, Service
from .utils import EC_CURVES, EKU_OIDS
class CertificateService(Service):
class Config:
cli_namespace = 'system.certificate'
@private
async def get_domain_names(self, cert_id):
... | 1,881 | Python | .py | 50 | 30.28 | 110 | 0.639407 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,978 | dependencies.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/dependencies.py | from middlewared.service import CallError, private, Service
class CertificateService(Service):
@private
async def check_cert_deps(self, cert_id):
if deps := await self.middleware.call('certificate.get_attachments', cert_id):
deps_str = ''
for i, svc in enumerate(deps):
... | 454 | Python | .py | 9 | 41.555556 | 94 | 0.647059 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,979 | ca_profiles.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/ca_profiles.py | from middlewared.schema import accepts, Dict, returns
from middlewared.service import Service
from .utils import DEFAULT_LIFETIME_DAYS
class CertificateAuthorityService(Service):
class Config:
cli_namespace = 'system.certificate.authority'
PROFILES = {
'CA': {
'key_length': 2048... | 1,542 | Python | .py | 43 | 23.651163 | 107 | 0.529806 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,980 | csr.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/csr.py | import typing
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from .extensions_utils import add_extensions
from .generate_utils import generate_builder, normalize_san
from .key_utils import export_private_key_object, generate_private_key, retrieve_sign... | 1,232 | Python | .py | 25 | 43.52 | 98 | 0.694167 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,981 | revoke_ca.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/revoke_ca.py | from middlewared.service import periodic, private, Service
from middlewared.utils.time_utils import utc_now
from .query_utils import get_ca_chain
class CertificateAuthorityService(Service):
class Config:
cli_namespace = 'system.certificate.authority'
@periodic(86400, run_on_start=True)
@private... | 1,219 | Python | .py | 28 | 34.285714 | 115 | 0.613176 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,982 | default_cert.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/default_cert.py | from middlewared.service import private, Service
from .utils import CERT_TYPE_EXISTING, DEFAULT_CERT_NAME
class CertificateService(Service):
@private
async def setup_self_signed_cert_for_ui(self, cert_name=DEFAULT_CERT_NAME):
cert_id = None
index = 1
while not cert_id:
ce... | 1,930 | Python | .py | 44 | 32.204545 | 120 | 0.577517 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,983 | load_utils.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/load_utils.py | import datetime
import dateutil
import dateutil.parser
import logging
import re
from contextlib import suppress
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import dsa, ec, ed25519, ed448, rsa
from OpenS... | 6,099 | Python | .py | 133 | 37.879699 | 111 | 0.640451 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,984 | cert_entry.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/cert_entry.py | import copy
from middlewared.schema import Bool, Datetime, Dict, Int, List, OROperator, Str
CERT_ENTRY = Dict(
'certificate_entry',
Int('id'),
Int('type'),
Str('name'),
Str('certificate', null=True, max_length=None),
Str('privatekey', null=True, max_length=None, private=True),
Str('CSR', ... | 2,292 | Python | .py | 67 | 29.253731 | 79 | 0.64009 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,985 | certificates.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/certificates.py | import datetime
import josepy as jose
from acme import errors, messages
from OpenSSL import crypto
import middlewared.sqlalchemy as sa
from middlewared.schema import accepts, Bool, Dict, Int, List, Patch, Ref, Str
from middlewared.service import CallError, CRUDService, job, private, skip_arg, ValidationErrors
from m... | 26,539 | Python | .py | 612 | 31.362745 | 118 | 0.556684 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,986 | generate_utils.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/generate_utils.py | import datetime
import ipaddress
import random
import typing
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from cryptography.x509.oid import NameOID
from middlewared.utils.time_utils import utc_now
from middlewared.valid... | 3,898 | Python | .py | 95 | 33.8 | 116 | 0.648692 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,987 | sign_csr.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/sign_csr.py | from middlewared.schema import accepts, Dict, Int, Ref, returns, Str
from middlewared.service import private, Service, ValidationErrors
from .utils import CERT_TYPE_INTERNAL
class CertificateAuthorityService(Service):
class Config:
cli_namespace = 'system.certificate.authority'
@accepts(
Di... | 4,849 | Python | .py | 118 | 28.161017 | 112 | 0.520705 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,988 | query_utils.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/query_utils.py | import copy
import logging
import os
from collections import defaultdict
from cryptography.hazmat.primitives.asymmetric import dsa, ec, rsa
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from typing import Union
from .load_utils import load_certificate, load_certificate_request, load_... | 6,655 | Python | .py | 146 | 37.034247 | 109 | 0.609903 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,989 | utils.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/utils.py | import re
from cryptography import x509
CERT_BACKEND_MAPPINGS = {
'common_name': 'common',
'country_name': 'country',
'state_or_province_name': 'state',
'locality_name': 'city',
'organization_name': 'organization',
'organizational_unit_name': 'organizational_unit',
'email_address': 'email... | 2,006 | Python | .py | 59 | 30.423729 | 104 | 0.665807 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,990 | __init__.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/__init__.py | from .utils import CERT_TYPE_EXISTING
async def setup(middleware):
failure = False
try:
system_general_config = await middleware.call('system.general.config')
system_cert = system_general_config['ui_certificate']
certs = await middleware.call('datastore.query', 'system.certificate', []... | 1,057 | Python | .py | 21 | 41.714286 | 103 | 0.658915 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,991 | cert_profiles.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/cert_profiles.py | import copy
from middlewared.schema import accepts, Dict, returns
from middlewared.service import Service
from .utils import DEFAULT_LIFETIME_DAYS
CERTIFICATE_PROFILES = {
# Options / EKUs reference rfc5246
'HTTPS RSA Certificate': {
'cert_extensions': {
'BasicConstraints': {
... | 4,203 | Python | .py | 111 | 26.414414 | 99 | 0.556317 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,992 | certificate_authorities.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/certificate_authorities.py | import random
from middlewared.schema import accepts, Bool, Dict, Int, Patch, Str
from middlewared.service import CRUDService, private, ValidationErrors
import middlewared.sqlalchemy as sa
from .cert_entry import get_ca_result_entry
from .common_validation import _validate_common_attributes, validate_cert_name
from .... | 18,871 | Python | .py | 417 | 33.023981 | 116 | 0.559562 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,993 | renew_certs.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/renew_certs.py | import datetime
from .generate_self_signed import generate_self_signed_certificate
from middlewared.service import job, periodic, private, Service
from middlewared.utils.time_utils import utc_now
class CertificateService(Service):
@periodic(86400)
@private
@job(lock='acme_cert_renewal')
def renew_ce... | 2,861 | Python | .py | 71 | 26.225352 | 104 | 0.489921 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,994 | cryptokey_validate.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/cryptokey_validate.py | import itertools
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from OpenSSL import crypto, SSL
from middlewared.service import Service
from .load_utils import load_private_key
from .utils import RE_CERTIFICATE
class CryptoKe... | 2,987 | Python | .py | 65 | 34.492308 | 109 | 0.622337 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,995 | key_utils.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/key_utils.py | import typing
from cryptography.hazmat.primitives.asymmetric import dsa, ec, ed25519, ed448, rsa
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes, serialization
from middlewared.sc... | 2,810 | Python | .py | 77 | 30.025974 | 101 | 0.691912 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,996 | generate_certs.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/generate_certs.py | import typing
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from .extensions_utils import add_extensions
from .generate_utils import generate_builder, normalize_san
from .key_utils import export_private_key_object, gener... | 1,837 | Python | .py | 41 | 38.585366 | 99 | 0.680291 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,997 | cryptokey_load.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/cryptokey_load.py | from middlewared.schema import accepts, Str
from middlewared.service import Service
from .load_utils import load_certificate, load_certificate_request
class CryptoKeyService(Service):
class Config:
private = True
@accepts(Str('certificate', required=True, max_length=None))
def load_certificate(... | 533 | Python | .py | 12 | 39.25 | 66 | 0.757282 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,998 | cryptokey_extensions.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/cryptokey_extensions.py | from cryptography import x509
from middlewared.schema import accepts, Ref, Str
from middlewared.service import Service, ValidationErrors
from .extensions_utils import get_extension_params
class CryptoKeyService(Service):
class Config:
private = True
@accepts(
Ref('cert_extensions'),
... | 1,827 | Python | .py | 37 | 38.135135 | 115 | 0.62507 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |
24,999 | generate_ca.py | truenas_middleware/src/middlewared/middlewared/plugins/crypto_/generate_ca.py | import typing
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from .extensions_utils import add_extensions
from .generate_utils import generate_builder, normalize_san
from .key_utils import export_private_key_object, gener... | 1,853 | Python | .py | 41 | 38.97561 | 99 | 0.680355 | truenas/middleware | 2,277 | 481 | 13 | LGPL-3.0 | 9/5/2024, 5:13:34 PM (Europe/Amsterdam) |