Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce396b1bcb | ||
|
|
dbfd742112 | ||
|
|
8cc1953d55 | ||
|
|
ad3b71e0d7 | ||
|
|
aca3df1078 | ||
|
|
686aa52fe7 | ||
|
|
db40ce2a02 | ||
|
|
f6236debaf | ||
|
|
13bb950ee3 | ||
|
|
29b620a4fb | ||
|
|
17ae8fbac0 | ||
|
|
8ac40ec030 |
No files matched your search
@@ -16,7 +16,7 @@ on:
|
||||
env:
|
||||
NODE_VERSION: '24'
|
||||
PNPM_VERSION: '10.28.1'
|
||||
GOLANG_BUILD_IMAGE: 'golang:1.25.12-alpine3.23@sha256:cc985ef6f9c3bf9ece7488129c9abe0a150388ccdfa428d886fc709dca0b230a'
|
||||
GOLANG_BUILD_IMAGE: 'golang:1.25.13-alpine3.23@sha256:42fc3368d1c50170a452f2bf4a1dfd292a065870c3f258d799aad4316671cb69'
|
||||
|
||||
jobs:
|
||||
determine-release-type:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# Table of Contents
|
||||
|
||||
* [Changelog for 8.0.8](#changelog-for-808-2026-08-20)
|
||||
* [Changelog for 8.0.7](#changelog-for-807-2026-07-31)
|
||||
* [Changelog for 8.0.6](#changelog-for-806-2026-07-15)
|
||||
* [Changelog for 8.0.5](#changelog-for-805-2026-06-18)
|
||||
@@ -66,6 +67,67 @@
|
||||
* [Changelog for 1.1.0](#changelog-for-110-2021-01-22)
|
||||
* [Changelog for 1.0.0](#changelog-for-100-2020-12-17)
|
||||
|
||||
# Changelog for [8.0.8] (2026-08-20)
|
||||
|
||||
The following sections list the changes for 8.0.8.
|
||||
|
||||
[8.0.8]: https://github.com/owncloud/ocis/compare/v8.0.7...v8.0.8
|
||||
|
||||
## Summary
|
||||
|
||||
* Security - Bump golang.org/x/image to v0.45.0: [#12808](https://github.com/owncloud/ocis/pull/12808)
|
||||
* Security - Bump Go to 1.25.13: [#12832](https://github.com/owncloud/ocis/pull/12832)
|
||||
* Bugfix - Cache LDAP instance mapper lookups: [#12823](https://github.com/owncloud/ocis/pull/12823)
|
||||
* Bugfix - Fix share metadata corruption during concurrent share operations: [#12621](https://github.com/owncloud/ocis/pull/12621)
|
||||
* Enhancement - Add TLS support for NATS store and registry connections: [#12765](https://github.com/owncloud/ocis/pull/12765)
|
||||
|
||||
## Details
|
||||
|
||||
* Security - Bump golang.org/x/image to v0.45.0: [#12808](https://github.com/owncloud/ocis/pull/12808)
|
||||
|
||||
Upgraded golang.org/x/image from v0.44.0 to v0.45.0 to address
|
||||
GO-2026-6222: excessive memory allocation during VP8L decoding.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12808
|
||||
|
||||
* Security - Bump Go to 1.25.13: [#12832](https://github.com/owncloud/ocis/pull/12832)
|
||||
|
||||
Fixes a stdlib CVE vulnerability flagged by the release image scan.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12832
|
||||
|
||||
* Bugfix - Cache LDAP instance mapper lookups: [#12823](https://github.com/owncloud/ocis/pull/12823)
|
||||
|
||||
In multi-instance deployments, resolving a user's instance name/ID during
|
||||
`GET /graph/v1.0/users` (and group member expansion) issued a fresh, uncached
|
||||
LDAP search per instance/guest attribute value on every request. Under load
|
||||
this multiplied into large numbers of redundant LDAP round-trips per page of
|
||||
users, saturating the LDAP connection pool and causing request timeouts. The
|
||||
LDAP identity backend now caches instance mapper lookups, including negative
|
||||
(not-found) results, for a configurable TTL
|
||||
(`OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL`, default 60s).
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12823
|
||||
|
||||
* Bugfix - Fix share metadata corruption during concurrent share operations: [#12621](https://github.com/owncloud/ocis/pull/12621)
|
||||
|
||||
When multiple sharing service replicas processed share operations concurrently
|
||||
for the same user, the share metadata could become corrupted with references to
|
||||
missing data, making all shares inaccessible to that user. The received share
|
||||
cache now uses compare-and-swap (etag) validation to detect concurrent writes
|
||||
and retries gracefully, preventing metadata corruption.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12621
|
||||
|
||||
* Enhancement - Add TLS support for NATS store and registry connections: [#12765](https://github.com/owncloud/ocis/pull/12765)
|
||||
|
||||
All `nats-js-kv` store, cache, and service registry connections now support
|
||||
TLS. Configure via `OCIS_CACHE_ENABLE_TLS`, `OCIS_PERSISTENT_STORE_ENABLE_TLS`,
|
||||
and `MICRO_REGISTRY_ENABLE_TLS`, with corresponding `*_TLS_INSECURE` and
|
||||
`*_TLS_ROOT_CA_CERTIFICATE` variants per connection type.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12765
|
||||
|
||||
# Changelog for [8.0.7] (2026-07-31)
|
||||
|
||||
The following sections list the changes for 8.0.7.
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ RUN make ci-go-generate build ENABLE_VIPS=true
|
||||
FROM alpine:3.23.3
|
||||
|
||||
RUN apk add --no-cache attr ca-certificates curl mailcap tree \
|
||||
&& apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community "vips=8.18.4-r1" \
|
||||
&& apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community "vips=8.18.5-r0" \
|
||||
&& echo 'hosts: files dns' >| /etc/nsswitch.conf
|
||||
|
||||
LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
Bugfix: Cache LDAP instance mapper lookups
|
||||
|
||||
In multi-instance deployments, resolving a user's instance name/ID during
|
||||
`GET /graph/v1.0/users` (and group member expansion) issued a fresh, uncached
|
||||
LDAP search per instance/guest attribute value on every request. Under load
|
||||
this multiplied into large numbers of redundant LDAP round-trips per page of
|
||||
users, saturating the LDAP connection pool and causing request timeouts. The
|
||||
LDAP identity backend now caches instance mapper lookups, including negative
|
||||
(not-found) results, for a configurable TTL
|
||||
(`OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL`, default 60s).
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12823
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,5 @@
|
||||
Security: Bump Go to 1.25.13
|
||||
|
||||
Fixes a stdlib CVE vulnerability flagged by the release image scan.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12832
|
||||
File renamed without changes.
@@ -0,0 +1,13 @@
|
||||
Bugfix: Remove the unmarshalable request body field from graph log messages
|
||||
|
||||
We've removed the `body` field from the log messages of the graph service's HTTP
|
||||
handlers. The field was set from `http.Request.Body`, an `io.ReadCloser`, which
|
||||
can never be serialized into a useful log value.
|
||||
|
||||
The tracing middleware replaces the request body with a wrapper that carries an
|
||||
exported function field, so serializing it failed outright and the log line was
|
||||
emitted with `"body": "marshaling error: json: unsupported type: func(int64)"`
|
||||
instead of the payload. Without the tracing middleware the field serialized to an
|
||||
empty object. In both cases the intended payload was never logged.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12918
|
||||
@@ -0,0 +1,28 @@
|
||||
Bugfix: Release the quota of upload sessions with unreadable node metadata
|
||||
|
||||
When an upload's target node lost its metadata, e.g. because an ancestor was
|
||||
moved to the trash while the upload was still in flight, the upload could never
|
||||
finish processing. It stayed in "Processing" forever, could not be downloaded or
|
||||
deleted, and kept consuming the space quota.
|
||||
|
||||
Cleaning such a session up with `ocis storage-users uploads sessions --clean`
|
||||
did not help either: it removed the uploaded bytes and the session info file
|
||||
before failing to revert the node, so it destroyed the only copy of the data
|
||||
without releasing any quota.
|
||||
|
||||
Cleanup now reverts the node before removing anything irreversible and falls
|
||||
back to the session metadata when the node cannot be read, so the quota is
|
||||
released and the orphaned node is removed. If the quota cannot be released the
|
||||
upload is kept so it can be retried instead of being lost.
|
||||
|
||||
A new `--orphaned` filter lists the affected sessions:
|
||||
|
||||
```
|
||||
ocis storage-users uploads sessions --orphaned
|
||||
ocis storage-users uploads sessions --orphaned --clean
|
||||
```
|
||||
|
||||
Note that evaluating the filter reads the node metadata of every session, so it
|
||||
is only done when the flag is set.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12739
|
||||
@@ -0,0 +1,25 @@
|
||||
Bugfix: Keep shares visible in sharedWithMe when a resource cannot be statted
|
||||
|
||||
The graph `sharedWithMe` handler resolves each received share by fanning out a per-resource
|
||||
`Stat` call with a concurrency limit, all sharing the request context. When a `Stat` failed
|
||||
for any reason (slow or stuck downstream, deleted space, gateway error, deadline exceeded)
|
||||
the worker logged at debug and returned without emitting a drive item, so the share was
|
||||
silently omitted from the response and the handler still returned `200 OK` with a partial,
|
||||
non-deterministic list. A single chronically-slow share could therefore make other,
|
||||
recently-accepted shares intermittently invisible, and repeated calls returned different
|
||||
subsets of the user's shares.
|
||||
|
||||
The handler now:
|
||||
|
||||
- bounds each per-share `Stat` with its own timeout derived from the request context, so one
|
||||
slow resource can no longer consume the deadline shared by all the other shares. The bound
|
||||
is configurable via `GRAPH_RECEIVED_SHARES_STAT_TIMEOUT` (default `10s`);
|
||||
- returns a degraded drive item built from the data already present in the share record
|
||||
(ids, permissions, grantees, timestamps, mountpoint name) when the resource cannot be statted
|
||||
due to a transient or indeterminate failure (timeout, slow or unavailable downstream), so the
|
||||
share stays visible instead of intermittently disappearing. A genuinely missing resource or
|
||||
revoked access (for example after the sharer was deleted) still drops the share, as before;
|
||||
- logs the dropped/degraded shares at warning level with a per-request count for operator
|
||||
visibility.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12430
|
||||
@@ -0,0 +1,10 @@
|
||||
Enhancement: Add TLS support for the frontend stat cache store connection
|
||||
|
||||
The frontend service was the only remaining place where a `nats-js-kv` store
|
||||
connection could not be secured. Its OCS stat cache forwarded the store type,
|
||||
nodes, database, table, TTL and credentials to reva, but not the TLS settings,
|
||||
so the connection stayed plaintext with no operator toggle to change it. The
|
||||
stat cache now honours `OCIS_CACHE_ENABLE_TLS`, `OCIS_CACHE_TLS_INSECURE` and
|
||||
`OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE` like every other cache and store.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12777
|
||||
@@ -0,0 +1,6 @@
|
||||
Bugfix: Correct introduction version for OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL
|
||||
|
||||
We changed the documented introduction version of the
|
||||
OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL from 8.0.0 to 8.3.0.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12949
|
||||
@@ -0,0 +1,12 @@
|
||||
Enhancement: The public link resolution flag added to PROPFIND
|
||||
|
||||
The public link resolution flag and the context timeout added to PROPFIND request
|
||||
The ocdav PROPFIND handler resolves public link shares to populate the oc:share-type property.
|
||||
A new toggle for skipping that lookup. The toggle is now exposed as
|
||||
OCDAV_DISABLE_PROPFIND_PUBLIC_LINK_RESOLUTION, which can be set to reduce load
|
||||
on services for large collections.
|
||||
Also, the bounded context was added for least public share request. Since this property is needed only
|
||||
to display an icon next to files in the list, indicating that a public link exists,
|
||||
it can be omitted if the ListPublicShares request is slow.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/13031
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/owncloud/ocis/v2
|
||||
|
||||
go 1.25.12
|
||||
go 1.25.13
|
||||
|
||||
require (
|
||||
dario.cat/mergo v1.0.2
|
||||
@@ -65,7 +65,7 @@ require (
|
||||
github.com/open-policy-agent/opa v1.19.0
|
||||
github.com/orcaman/concurrent-map v1.0.0
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260813081353-3dbd3c2711ea
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260930102649-8627a367787a
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pkg/xattr v0.4.12
|
||||
github.com/prometheus/client_golang v1.24.1
|
||||
@@ -95,17 +95,17 @@ require (
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.45.0
|
||||
go.opentelemetry.io/otel/sdk v1.45.0
|
||||
go.opentelemetry.io/otel/trace v1.45.0
|
||||
golang.org/x/crypto v0.54.0
|
||||
golang.org/x/crypto v0.55.0
|
||||
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f
|
||||
golang.org/x/image v0.45.0
|
||||
golang.org/x/net v0.57.0
|
||||
golang.org/x/net v0.58.0
|
||||
golang.org/x/oauth2 v0.36.0
|
||||
golang.org/x/sync v0.22.0
|
||||
golang.org/x/term v0.45.0
|
||||
golang.org/x/text v0.41.0
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260803160001-6ac0973c030d
|
||||
google.golang.org/grpc v1.83.0
|
||||
google.golang.org/protobuf v1.36.11
|
||||
google.golang.org/grpc v1.83.1
|
||||
google.golang.org/protobuf v1.36.12
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gotest.tools/v3 v3.5.2
|
||||
stash.kopano.io/kgol/rndm v1.1.2
|
||||
@@ -120,7 +120,7 @@ require (
|
||||
github.com/Masterminds/semver/v3 v3.5.0 // indirect
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
|
||||
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||
github.com/ProtonMail/go-crypto v1.1.6 // indirect
|
||||
github.com/ProtonMail/go-crypto v1.4.1 // indirect
|
||||
github.com/RoaringBitmap/roaring/v2 v2.14.5 // indirect
|
||||
github.com/agnivade/levenshtein v1.2.1 // indirect
|
||||
github.com/ajg/form v1.5.1 // indirect
|
||||
@@ -158,14 +158,14 @@ require (
|
||||
github.com/cevaris/ordered_map v0.0.0-20190319150403-3adeae072e73 // indirect
|
||||
github.com/clipperhouse/displaywidth v0.11.0 // indirect
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
|
||||
github.com/cloudflare/circl v1.6.3 // indirect
|
||||
github.com/cloudflare/circl v1.6.5 // indirect
|
||||
github.com/coreos/go-semver v0.3.1 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.7.0 // indirect
|
||||
github.com/cornelk/hashmap v1.0.8 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
|
||||
github.com/crewjam/httperr v0.2.0 // indirect
|
||||
github.com/crewjam/saml v0.4.14 // indirect
|
||||
github.com/cyphar/filepath-securejoin v0.6.1 // indirect
|
||||
github.com/cyphar/filepath-securejoin v0.7.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/deckarep/golang-set v1.8.0 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1 // indirect
|
||||
@@ -186,7 +186,7 @@ require (
|
||||
github.com/go-acme/lego/v4 v4.34.0 // indirect
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.8 // indirect
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.9.0 // indirect
|
||||
github.com/go-git/go-billy/v5 v5.9.1 // indirect
|
||||
github.com/go-git/go-git/v5 v5.19.2 // indirect
|
||||
github.com/go-jose/go-jose/v3 v3.0.5 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.1.4 // indirect
|
||||
@@ -238,9 +238,9 @@ require (
|
||||
github.com/jonboulle/clockwork v0.5.0 // indirect
|
||||
github.com/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12 // indirect
|
||||
github.com/juliangruber/go-intersect v1.1.0 // indirect
|
||||
github.com/kevinburke/ssh_config v1.2.0 // indirect
|
||||
github.com/kevinburke/ssh_config v1.6.0 // indirect
|
||||
github.com/klauspost/compress v1.19.1 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.4.0 // indirect
|
||||
github.com/klauspost/crc32 v1.3.0 // indirect
|
||||
github.com/kovidgoyal/go-parallel v1.1.1 // indirect
|
||||
github.com/kovidgoyal/go-shm v1.0.0 // indirect
|
||||
@@ -308,7 +308,7 @@ require (
|
||||
github.com/sercand/kuberesolver/v5 v5.1.1 // indirect
|
||||
github.com/sergi/go-diff v1.4.0 // indirect
|
||||
github.com/sethvargo/go-password v0.4.0 // indirect
|
||||
github.com/skeema/knownhosts v1.3.1 // indirect
|
||||
github.com/skeema/knownhosts v1.3.2 // indirect
|
||||
github.com/spacewander/go-suffix-tree v0.0.0-20191010040751-0865e368c784 // indirect
|
||||
github.com/spf13/pflag v1.0.10 // indirect
|
||||
github.com/stretchr/objx v0.5.3 // indirect
|
||||
@@ -340,12 +340,12 @@ require (
|
||||
go.uber.org/zap v1.27.1 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.4 // indirect
|
||||
go.yaml.in/yaml/v3 v3.0.5 // indirect
|
||||
golang.org/x/mod v0.38.0 // indirect
|
||||
golang.org/x/mod v0.40.0 // indirect
|
||||
golang.org/x/sys v0.47.0 // indirect
|
||||
golang.org/x/time v0.15.0 // indirect
|
||||
golang.org/x/tools v0.48.0 // indirect
|
||||
golang.org/x/tools v0.49.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260803160001-6ac0973c030d // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 // indirect
|
||||
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.3 // indirect
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
||||
|
||||
@@ -68,8 +68,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo
|
||||
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||
github.com/Nerzal/gocloak/v13 v13.9.0 h1:YWsJsdM5b0yhM2Ba3MLydiOlujkBry4TtdzfIzSVZhw=
|
||||
github.com/Nerzal/gocloak/v13 v13.9.0/go.mod h1:YYuDcXZ7K2zKECyVP7pPqjKxx2AzYSpKDj8d6GuyM10=
|
||||
github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw=
|
||||
github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
|
||||
github.com/ProtonMail/go-crypto v1.4.1 h1:9RfcZHqEQUvP8RzecWEUafnZVtEvrBVL9BiF67IQOfM=
|
||||
github.com/ProtonMail/go-crypto v1.4.1/go.mod h1:e1OaTyu5SYVrO9gKOEhTc+5UcXtTUa+P3uLudwcgPqo=
|
||||
github.com/RoaringBitmap/roaring/v2 v2.14.5 h1:ckd0o545JqDPeVJDgeFoaM21eBixUnlWfYgjE5VnyWw=
|
||||
github.com/RoaringBitmap/roaring/v2 v2.14.5/go.mod h1:eq4wdNXxtJIS/oikeCzdX1rBzek7ANzbth041hrU8Q4=
|
||||
github.com/agnivade/levenshtein v1.2.1 h1:EHBY3UOn1gwdy/VbFwgo4cxecRznFk7fKWN1KOX7eoM=
|
||||
@@ -183,8 +183,8 @@ github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSE
|
||||
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
||||
github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8=
|
||||
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
|
||||
github.com/cloudflare/circl v1.6.5 h1:O64F26HEqNhznd/hrC5KZXVKYuKM2rx4deZDTc4ihQA=
|
||||
github.com/cloudflare/circl v1.6.5/go.mod h1:h5LNyxAc5nTue9DS5jT+48en2PSDYt3zdGnz5OstK6c=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/coreos/go-oidc/v3 v3.20.0 h1:EtE0WIBHk03N+DqGkY4+UONzzZHk7amKt6IyNd7OsZE=
|
||||
github.com/coreos/go-oidc/v3 v3.20.0/go.mod h1:DYCf24+ncYi+XkIH97GY1+dqoRlbaSI26KVTCI9SrY4=
|
||||
@@ -203,8 +203,8 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c=
|
||||
github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME=
|
||||
github.com/cs3org/go-cs3apis v0.0.0-20241105092511-3ad35d174fc1 h1:RU6LT6mkD16xZs011+8foU7T3LrPvTTSWeTQ9OgfhkA=
|
||||
github.com/cs3org/go-cs3apis v0.0.0-20241105092511-3ad35d174fc1/go.mod h1:DedpcqXl193qF/08Y04IO0PpxyyMu8+GrkD6kWK2MEQ=
|
||||
github.com/cyphar/filepath-securejoin v0.6.1 h1:5CeZ1jPXEiYt3+Z6zqprSAgSWiggmpVyciv8syjIpVE=
|
||||
github.com/cyphar/filepath-securejoin v0.6.1/go.mod h1:A8hd4EnAeyujCJRrICiOWqjS1AX0a9kM5XL+NwKoYSc=
|
||||
github.com/cyphar/filepath-securejoin v0.7.0 h1:s0Y3ITPy6sQn5xt54DuYvTF8hu134ooYLUb58DX/HjE=
|
||||
github.com/cyphar/filepath-securejoin v0.7.0/go.mod h1:ymLGms/u3BYaviIiuKFnUx8EkQEZeK6cInNoAPJA3o4=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
@@ -292,8 +292,8 @@ github.com/go-chi/render v1.0.3 h1:AsXqd2a1/INaIfUSKq3G5uA8weYx20FOsM7uSoCyyt4=
|
||||
github.com/go-chi/render v1.0.3/go.mod h1:/gr3hVkmYR0YlEy3LxCuVRFzEu9Ruok+gFqbIofjao0=
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
|
||||
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
|
||||
github.com/go-git/go-billy/v5 v5.9.0 h1:jItGXszUDRtR/AlferWPTMN4j38BQ88XnXKbilmmBPA=
|
||||
github.com/go-git/go-billy/v5 v5.9.0/go.mod h1:jCnQMLj9eUgGU7+ludSTYoZL/GGmii14RxKFj7ROgHw=
|
||||
github.com/go-git/go-billy/v5 v5.9.1 h1:8U73XiOTfINdItHVa6z4Gv7ToObcZ6grkqQbLryLCdA=
|
||||
github.com/go-git/go-billy/v5 v5.9.1/go.mod h1:ExsU+jcGwXTBOnyilvAnEM1wug1IxHr4yP2ZXsNRtV0=
|
||||
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
|
||||
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
|
||||
github.com/go-git/go-git/v5 v5.19.2 h1:wkfn7vOlUBu8ivAWKBWisTiwJK4jYHzTF8Ndv1LyGqY=
|
||||
@@ -568,15 +568,15 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
|
||||
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
|
||||
github.com/justinas/alice v1.2.0 h1:+MHSA/vccVCF4Uq37S42jwlkvI2Xzl7zTPCN5BnZNVo=
|
||||
github.com/justinas/alice v1.2.0/go.mod h1:fN5HRH/reO/zrUflLfTN43t3vXvKzvZIENsNEe7i7qA=
|
||||
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
|
||||
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
||||
github.com/kevinburke/ssh_config v1.6.0 h1:J1FBfmuVosPHf5GRdltRLhPJtJpTlMdKTBjRgTaQBFY=
|
||||
github.com/kevinburke/ssh_config v1.6.0/go.mod h1:q2RIzfka+BXARoNexmF9gkxEX7DmvbW9P4hIVx2Kg4M=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.19.1 h1:VsB4HPswih7mmZ8WleSFQ75c/Ui1M4trX5oAsJnhSlk=
|
||||
github.com/klauspost/compress v1.19.1/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
|
||||
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/klauspost/cpuid/v2 v2.4.0 h1:S6Hrbc7+ywsr0r+RLapfGBHfyefhCTwEh3A0tV913Dw=
|
||||
github.com/klauspost/cpuid/v2 v2.4.0/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU=
|
||||
github.com/klauspost/crc32 v1.3.0 h1:sSmTt3gUt81RP655XGZPElI0PelVTZ6YwCRnPSupoFM=
|
||||
github.com/klauspost/crc32 v1.3.0/go.mod h1:D7kQaZhnkX/Y0tstFGf8VUzv2UofNGqCjnC3zdHB0Hw=
|
||||
github.com/kobergj/go-micro/v4 v4.0.0-20250610135441-d0b187215699 h1:3TOdtI6WPyvBB+uCykapjRtQX8vTHMlyhINzR+58B4k=
|
||||
@@ -735,8 +735,8 @@ github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HD
|
||||
github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245 h1:JRidLTAKhnvyLMRtVtSF4lhBa0NSAOs6fof+d6JnKII=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260216101009-eeac018af245/go.mod h1:z61VMGAJRtR1nbgXWiNoCkxUXP1B3Je9rMuJbnGd+Og=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260813081353-3dbd3c2711ea h1:68rl8e2cYHE46s+PFJRpp0IP4VLyqAILQE8GD9F2FjE=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260813081353-3dbd3c2711ea/go.mod h1:LSXqMWTC7Ya6uxmqp1ksrWYZXBuZ6PhcmVimxyG8U5o=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260930102649-8627a367787a h1:fOgWtuGNLctt2DIGiGamcq65RpHY3yqHhSUEWnV5cts=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260930102649-8627a367787a/go.mod h1:LSXqMWTC7Ya6uxmqp1ksrWYZXBuZ6PhcmVimxyG8U5o=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
||||
github.com/pablodz/inotifywaitgo v0.0.12 h1:DVJJTFMDlSAdO46yisPF2vzozs/r+4k6ih8MVghq78M=
|
||||
@@ -847,8 +847,8 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf
|
||||
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w=
|
||||
github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g=
|
||||
github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8=
|
||||
github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY=
|
||||
github.com/skeema/knownhosts v1.3.2 h1:EDL9mgf4NzwMXCTfaxSD/o/a5fxDw/xL9nkU28JjdBg=
|
||||
github.com/skeema/knownhosts v1.3.2/go.mod h1:bEg3iQAuw+jyiw+484wwFJoKSLwcfd7fqRy+N0QTiow=
|
||||
github.com/spacewander/go-suffix-tree v0.0.0-20191010040751-0865e368c784 h1:0jjO3HdJfOn6gYHD/ZNZh0LLMxEAqkYX7xoDPQReEgs=
|
||||
github.com/spacewander/go-suffix-tree v0.0.0-20191010040751-0865e368c784/go.mod h1:ff/5myEGgtsAwf26goQCO905GrEm5ugEZSd6OWTsrhM=
|
||||
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
|
||||
@@ -1014,8 +1014,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw=
|
||||
golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk=
|
||||
golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M=
|
||||
golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@@ -1053,8 +1053,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk=
|
||||
golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40=
|
||||
golang.org/x/mod v0.40.0 h1:hUv+3cXcdRHz08UmSiOob7sadHig73uo5bkXxQ/tvUs=
|
||||
golang.org/x/mod v0.40.0/go.mod h1:0/weTWkPWGBikyTWAX3dkjVztMmBA5hM0DH6BElSupE=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -1098,8 +1098,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
|
||||
golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
|
||||
golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To=
|
||||
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@@ -1263,8 +1263,8 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f
|
||||
golang.org/x/tools v0.0.0-20210112230658-8b4aab62c064/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE=
|
||||
golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk=
|
||||
golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI=
|
||||
golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@@ -1327,8 +1327,8 @@ google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7 h1:XzmzkmB14QhVhgn
|
||||
google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7/go.mod h1:L43LFes82YgSonw6iTXTxXUX1OlULt4AQtkik4ULL/I=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260803160001-6ac0973c030d h1:FarXi840EJWSHYTN3ERkADbPWjl307+FGrA22KAVjjc=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20260803160001-6ac0973c030d/go.mod h1:K/+WGbmBY7aNW1HDw1fJnKYo10i0DkAX6pows00dLig=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260803160001-6ac0973c030d h1:IL4hdHzcUv2l/gcg98/Rj3FbtE6axwqslOW8SW0C+S0=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260803160001-6ac0973c030d/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688 h1:cYNAzI2sUwhmCcoj9TxvihSrqsxt6uIkj3rDRhSDmW4=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20260819154853-08b0e4226688/go.mod h1:DjtHYE8FKJLivXcBEjGwndXfIC23G0VpXiXKqG179uA=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
@@ -1342,8 +1342,8 @@ google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3Iji
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
google.golang.org/grpc v1.83.0 h1:JeNZEKJFbQxArAMl+hiytHauacDNqJUllNfmIMmpqnQ=
|
||||
google.golang.org/grpc v1.83.0/go.mod h1:kDyl6SKsiHKt0uylY5gtn5cEjkrIOhQOGDgIc4JGwzQ=
|
||||
google.golang.org/grpc v1.83.1 h1:HIO0+BEtBP6soyqvqC8sNUjZ7bTs+0hFQuFF+RAy++Y=
|
||||
google.golang.org/grpc v1.83.1/go.mod h1:kDyl6SKsiHKt0uylY5gtn5cEjkrIOhQOGDgIc4JGwzQ=
|
||||
google.golang.org/grpc/examples v0.0.0-20211102180624-670c133e568e h1:m7aQHHqd0q89mRwhwS9Bx2rjyl/hsFAeta+uGrHsQaU=
|
||||
google.golang.org/grpc/examples v0.0.0-20211102180624-670c133e568e/go.mod h1:gID3PKrg7pWKntu9Ss6zTLJ0ttC0X9IHgREOCZwbCVU=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
@@ -1360,8 +1360,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
|
||||
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
|
||||
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||
gopkg.in/cenkalti/backoff.v1 v1.1.0 h1:Arh75ttbsvlpVA7WtVpH4u9h6Zl46xuptxqLxPiSo4Y=
|
||||
gopkg.in/cenkalti/backoff.v1 v1.1.0/go.mod h1:J6Vskwqd+OMVJl8C33mmtxTBs2gyzfv7UDAkHu8BrjI=
|
||||
|
||||
@@ -16,7 +16,7 @@ var (
|
||||
// LatestTag is the latest released version plus the dev meta version.
|
||||
// Will be overwritten by the release pipeline
|
||||
// Needs a manual change for every tagged release
|
||||
LatestTag = "8.0.7"
|
||||
LatestTag = "8.0.8"
|
||||
|
||||
// Date indicates the build date.
|
||||
// This has been removed, it looks like you can only replace static strings with recent go versions
|
||||
|
||||
@@ -5,7 +5,7 @@ ARG REVISION=""
|
||||
|
||||
RUN apk upgrade --no-cache \
|
||||
&& apk add --no-cache attr bash ca-certificates curl inotify-tools libc6-compat mailcap tree patch \
|
||||
&& apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community "vips=8.18.4-r1" \
|
||||
&& apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community "vips=8.18.5-r0" \
|
||||
&& echo 'hosts: files dns' >| /etc/nsswitch.conf
|
||||
|
||||
LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
|
||||
|
||||
@@ -5,7 +5,7 @@ ARG REVISION=""
|
||||
|
||||
RUN apk upgrade --no-cache \
|
||||
&& apk add --no-cache attr bash ca-certificates curl inotify-tools libc6-compat mailcap tree patch \
|
||||
&& apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community "vips=8.18.4-r1" \
|
||||
&& apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community "vips=8.18.5-r0" \
|
||||
&& echo 'hosts: files dns' >| /etc/nsswitch.conf
|
||||
|
||||
LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
|
||||
|
||||
@@ -5,7 +5,7 @@ ARG REVISION=""
|
||||
|
||||
RUN apk upgrade --no-cache \
|
||||
&& apk add --no-cache attr bash ca-certificates curl delve inotify-tools libc6-compat mailcap tree patch \
|
||||
&& apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community "vips=8.18.4-r1" \
|
||||
&& apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community "vips=8.18.5-r0" \
|
||||
&& echo 'hosts: files dns' >| /etc/nsswitch.conf
|
||||
|
||||
LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
|
||||
|
||||
@@ -5,7 +5,7 @@ ARG REVISION=""
|
||||
|
||||
RUN apk upgrade --no-cache \
|
||||
&& apk add --no-cache attr bash ca-certificates curl delve inotify-tools libc6-compat mailcap tree patch \
|
||||
&& apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community "vips=8.18.4-r1" \
|
||||
&& apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community "vips=8.18.5-r0" \
|
||||
&& echo 'hosts: files dns' >| /etc/nsswitch.conf
|
||||
|
||||
LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
|
||||
|
||||
@@ -131,18 +131,21 @@ type DataGateway struct {
|
||||
}
|
||||
|
||||
type OCS struct {
|
||||
Prefix string `yaml:"prefix" desc:"URL path prefix for the OCS service. Note that the string must not start with '/'." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
SharePrefix string `yaml:"share_prefix" desc:"Path prefix for shares as part of an ocis resource. Note that the path must start with '/'." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
HomeNamespace string `yaml:"home_namespace" desc:"Home namespace identifier." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
AdditionalInfoAttribute string `yaml:"additional_info_attribute" desc:"Additional information attribute for the user like {{.Mail}}." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheType string `yaml:"stat_cache_type" env:"OCIS_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'redis-sentinel', 'nats-js-kv', 'noop'. See the text description for details." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_STORE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheNodes []string `yaml:"stat_cache_nodes" env:"OCIS_CACHE_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' store is configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_STORE_NODES in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheDatabase string `yaml:"stat_cache_database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_DATABASE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheTable string `yaml:"stat_cache_table" desc:"The database table the store should use." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheTTL time.Duration `yaml:"stat_cache_ttl" env:"OCIS_CACHE_TTL" desc:"Default time to live for user info in the cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_TTL in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheDisablePersistence bool `yaml:"stat_cache_disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE" desc:"Disable persistence of the cache. Only applies when using the 'nats-js-kv' store type. Defaults to false." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_DISABLE_PERSISTENCE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheAuthUsername string `yaml:"stat_cache_auth_username" env:"OCIS_CACHE_AUTH_USERNAME" desc:"The username to use for authentication. Only applies when using the 'nats-js-kv' store type." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_AUTH_USERNAME in the frontend service is deprecated because the OCS API is deprecated OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheAuthPassword string `yaml:"stat_cache_auth_password" env:"OCIS_CACHE_AUTH_PASSWORD" desc:"The password to use for authentication. Only applies when using the 'nats-js-kv' store type." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_AUTH_PASSWORD in the frontend service is deprecated because the OCS API is deprecated OCS API is deprecated" deprecationReplacement:""`
|
||||
Prefix string `yaml:"prefix" desc:"URL path prefix for the OCS service. Note that the string must not start with '/'." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
SharePrefix string `yaml:"share_prefix" desc:"Path prefix for shares as part of an ocis resource. Note that the path must start with '/'." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
HomeNamespace string `yaml:"home_namespace" desc:"Home namespace identifier." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
AdditionalInfoAttribute string `yaml:"additional_info_attribute" desc:"Additional information attribute for the user like {{.Mail}}." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheType string `yaml:"stat_cache_type" env:"OCIS_CACHE_STORE" desc:"The type of the cache store. Supported values are: 'memory', 'redis-sentinel', 'nats-js-kv', 'noop'. See the text description for details." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_STORE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheNodes []string `yaml:"stat_cache_nodes" env:"OCIS_CACHE_STORE_NODES" desc:"A list of nodes to access the configured store. This has no effect when 'memory' store is configured. Note that the behaviour how nodes are used is dependent on the library of the configured store. See the Environment Variable Types description for more details." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_STORE_NODES in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheDatabase string `yaml:"stat_cache_database" env:"OCIS_CACHE_DATABASE" desc:"The database name the configured store should use." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_DATABASE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheTable string `yaml:"stat_cache_table" desc:"The database table the store should use." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheTTL time.Duration `yaml:"stat_cache_ttl" env:"OCIS_CACHE_TTL" desc:"Default time to live for user info in the cache. Only applied when access tokens has no expiration. See the Environment Variable Types description for more details." introductionVersion:"pre5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_TTL in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheDisablePersistence bool `yaml:"stat_cache_disable_persistence" env:"OCIS_CACHE_DISABLE_PERSISTENCE" desc:"Disable persistence of the cache. Only applies when using the 'nats-js-kv' store type. Defaults to false." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_DISABLE_PERSISTENCE in the frontend service is deprecated because the OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheAuthUsername string `yaml:"stat_cache_auth_username" env:"OCIS_CACHE_AUTH_USERNAME" desc:"The username to use for authentication. Only applies when using the 'nats-js-kv' store type." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_AUTH_USERNAME in the frontend service is deprecated because the OCS API is deprecated OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheAuthPassword string `yaml:"stat_cache_auth_password" env:"OCIS_CACHE_AUTH_PASSWORD" desc:"The password to use for authentication. Only applies when using the 'nats-js-kv' store type." introductionVersion:"5.0" deprecationVersion:"7.0.0" removalVersion:"%%NEXT_PRODUCTION_VERSION%%" deprecationInfo:"The use of OCIS_CACHE_AUTH_PASSWORD in the frontend service is deprecated because the OCS API is deprecated OCS API is deprecated" deprecationReplacement:""`
|
||||
StatCacheEnableTLS bool `yaml:"stat_cache_enable_tls" env:"OCIS_CACHE_ENABLE_TLS" desc:"Activate TLS for the connection to the stat cache store. Only applies when using the 'nats-js-kv' store type." introductionVersion:"8.3.0"`
|
||||
StatCacheTLSInsecure bool `yaml:"stat_cache_tls_insecure" env:"OCIS_CACHE_TLS_INSECURE" desc:"Disable TLS certificate verification for the stat cache store connection. Only applies when using the 'nats-js-kv' store type." introductionVersion:"8.3.0"`
|
||||
StatCacheTLSRootCACertificate string `yaml:"stat_cache_tls_root_ca_certificate" env:"OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE" desc:"Path to the PEM-encoded root CA certificate for the stat cache store TLS connection. Only applies when using the 'nats-js-kv' store type." introductionVersion:"8.3.0"`
|
||||
|
||||
CacheWarmupDriver string `yaml:"cache_warmup_driver,omitempty"` // not supported by the oCIS product, therefore not part of docs
|
||||
CacheWarmupDrivers CacheWarmupDrivers `yaml:"cache_warmup_drivers,omitempty"` // not supported by the oCIS product, therefore not part of docs
|
||||
|
||||
@@ -163,14 +163,17 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string
|
||||
"share_prefix": cfg.OCS.SharePrefix,
|
||||
"home_namespace": cfg.OCS.HomeNamespace,
|
||||
"stat_cache_config": map[string]interface{}{
|
||||
"cache_store": cfg.OCS.StatCacheType,
|
||||
"cache_nodes": cfg.OCS.StatCacheNodes,
|
||||
"cache_database": cfg.OCS.StatCacheDatabase,
|
||||
"cache_table": cfg.OCS.StatCacheTable,
|
||||
"cache_ttl": cfg.OCS.StatCacheTTL,
|
||||
"cache_disable_persistence": cfg.OCS.StatCacheDisablePersistence,
|
||||
"cache_auth_username": cfg.OCS.StatCacheAuthUsername,
|
||||
"cache_auth_password": cfg.OCS.StatCacheAuthPassword,
|
||||
"cache_store": cfg.OCS.StatCacheType,
|
||||
"cache_nodes": cfg.OCS.StatCacheNodes,
|
||||
"cache_database": cfg.OCS.StatCacheDatabase,
|
||||
"cache_table": cfg.OCS.StatCacheTable,
|
||||
"cache_ttl": cfg.OCS.StatCacheTTL,
|
||||
"cache_disable_persistence": cfg.OCS.StatCacheDisablePersistence,
|
||||
"cache_auth_username": cfg.OCS.StatCacheAuthUsername,
|
||||
"cache_auth_password": cfg.OCS.StatCacheAuthPassword,
|
||||
"cache_enable_tls": cfg.OCS.StatCacheEnableTLS,
|
||||
"cache_tls_insecure": cfg.OCS.StatCacheTLSInsecure,
|
||||
"cache_tls_root_ca_certificate": cfg.OCS.StatCacheTLSRootCACertificate,
|
||||
},
|
||||
"prefix": cfg.OCS.Prefix,
|
||||
"additional_info_attribute": func() string {
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package revaconfig
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/envdecode"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/services/frontend/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func TestStatCacheTLSPlumbing(t *testing.T) {
|
||||
t.Setenv("OCIS_CACHE_ENABLE_TLS", "true")
|
||||
t.Setenv("OCIS_CACHE_TLS_INSECURE", "true")
|
||||
t.Setenv("OCIS_CACHE_TLS_ROOT_CA_CERTIFICATE", "/etc/ocis/ca.crt")
|
||||
|
||||
cfg := defaults.FullDefaultConfig()
|
||||
if err := envdecode.Decode(cfg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
revaCfg, err := FrontendConfigFromStruct(cfg, log.NopLogger())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
statCache := revaCfg["http"].(map[string]interface{})["services"].(map[string]interface{})["ocs"].(map[string]interface{})["stat_cache_config"].(map[string]interface{})
|
||||
t.Logf("cache_enable_tls=%v cache_tls_insecure=%v cache_tls_root_ca_certificate=%v",
|
||||
statCache["cache_enable_tls"], statCache["cache_tls_insecure"], statCache["cache_tls_root_ca_certificate"])
|
||||
|
||||
if statCache["cache_enable_tls"] != true {
|
||||
t.Errorf("cache_enable_tls = %v, want true", statCache["cache_enable_tls"])
|
||||
}
|
||||
if statCache["cache_tls_insecure"] != true {
|
||||
t.Errorf("cache_tls_insecure = %v, want true", statCache["cache_tls_insecure"])
|
||||
}
|
||||
if statCache["cache_tls_root_ca_certificate"] != "/etc/ocis/ca.crt" {
|
||||
t.Errorf("cache_tls_root_ca_certificate = %v, want /etc/ocis/ca.crt", statCache["cache_tls_root_ca_certificate"])
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,8 @@ type Config struct {
|
||||
UnifiedRoles UnifiedRoles `yaml:"unified_roles"`
|
||||
MaxConcurrency int `yaml:"max_concurrency" env:"OCIS_MAX_CONCURRENCY;GRAPH_MAX_CONCURRENCY" desc:"The maximum number of concurrent requests the service will handle." introductionVersion:"7.0.0"`
|
||||
|
||||
ReceivedSharesStatTimeout time.Duration `yaml:"received_shares_stat_timeout" env:"GRAPH_RECEIVED_SHARES_STAT_TIMEOUT" desc:"The maximum duration to wait for the storage to respond while resolving a single received share's resource when listing 'sharedWithMe'. Bounding each resource lookup individually prevents one slow or unreachable resource from consuming the request deadline shared by all the other shares. A share whose resource cannot be statted within this time is still listed as a degraded item instead of being dropped. Defaults to '10s'. See the Environment Variable Types description for more details." introductionVersion:"8.2.0"`
|
||||
|
||||
Keycloak Keycloak `yaml:"keycloak"`
|
||||
ServiceAccount ServiceAccount `yaml:"service_account"`
|
||||
MultiInstance MultiInstanceConfig `yaml:"multi_instance"`
|
||||
@@ -56,15 +58,15 @@ type Spaces struct {
|
||||
}
|
||||
|
||||
type LDAP struct {
|
||||
URI string `yaml:"uri" env:"OCIS_LDAP_URI;GRAPH_LDAP_URI" desc:"URI of the LDAP Server to connect to. Supported URI schemes are 'ldaps://' and 'ldap://'" introductionVersion:"pre5.0"`
|
||||
CACert string `yaml:"cacert" env:"OCIS_LDAP_CACERT;GRAPH_LDAP_CACERT" desc:"Path/File name for the root CA certificate (in PEM format) used to validate TLS server certificates of the LDAP service. If not defined, the root directory derives from $OCIS_BASE_DATA_PATH/idm." introductionVersion:"pre5.0"`
|
||||
Insecure bool `yaml:"insecure" env:"OCIS_LDAP_INSECURE;GRAPH_LDAP_INSECURE" desc:"Disable TLS certificate validation for the LDAP connections. Do not set this in production environments." introductionVersion:"pre5.0"`
|
||||
BindDN string `yaml:"bind_dn" env:"OCIS_LDAP_BIND_DN;GRAPH_LDAP_BIND_DN" desc:"LDAP DN to use for simple bind authentication with the target LDAP server." introductionVersion:"pre5.0"`
|
||||
BindPassword string `yaml:"bind_password" env:"OCIS_LDAP_BIND_PASSWORD;GRAPH_LDAP_BIND_PASSWORD" desc:"Password to use for authenticating the 'bind_dn'." introductionVersion:"pre5.0"`
|
||||
UseServerUUID bool `yaml:"use_server_uuid" env:"GRAPH_LDAP_SERVER_UUID" desc:"If set to true, rely on the LDAP Server to generate a unique ID for users and groups, like when using 'entryUUID' as the user ID attribute." introductionVersion:"pre5.0"`
|
||||
UsePasswordModExOp bool `yaml:"use_password_modify_exop" env:"GRAPH_LDAP_SERVER_USE_PASSWORD_MODIFY_EXOP" desc:"Use the 'Password Modify Extended Operation' for updating user passwords." introductionVersion:"pre5.0"`
|
||||
WriteEnabled bool `yaml:"write_enabled" env:"OCIS_LDAP_SERVER_WRITE_ENABLED;GRAPH_LDAP_SERVER_WRITE_ENABLED" desc:"Allow creating, modifying and deleting LDAP users via the GRAPH API. This can only be set to 'true' when keeping default settings for the LDAP user and group attribute types (the 'OCIS_LDAP_USER_SCHEMA_* and 'OCIS_LDAP_GROUP_SCHEMA_* variables)." introductionVersion:"pre5.0"`
|
||||
UpdateUserLastSignInDate bool `yaml:"update_user_last_sign_in_date" env:"OCIS_LDAP_UPDATE_LAST_SIGNIN_DATE;GRAPH_LDAP_UPDATE_LAST_SIGNIN_DATE" desc:"Update the 'oCLastSignInTimestamp' LDAP attribute of a user when the user signs in. The attribute is only persisted when 'OCIS_LDAP_SERVER_WRITE_ENABLED' is also enabled. Set this to 'false' to avoid an LDAP write on every sign-in, e.g. when the last sign-in timestamp is not needed or the LDAP write load should be reduced." introductionVersion:"8.2.0"`
|
||||
URI string `yaml:"uri" env:"OCIS_LDAP_URI;GRAPH_LDAP_URI" desc:"URI of the LDAP Server to connect to. Supported URI schemes are 'ldaps://' and 'ldap://'" introductionVersion:"pre5.0"`
|
||||
CACert string `yaml:"cacert" env:"OCIS_LDAP_CACERT;GRAPH_LDAP_CACERT" desc:"Path/File name for the root CA certificate (in PEM format) used to validate TLS server certificates of the LDAP service. If not defined, the root directory derives from $OCIS_BASE_DATA_PATH/idm." introductionVersion:"pre5.0"`
|
||||
Insecure bool `yaml:"insecure" env:"OCIS_LDAP_INSECURE;GRAPH_LDAP_INSECURE" desc:"Disable TLS certificate validation for the LDAP connections. Do not set this in production environments." introductionVersion:"pre5.0"`
|
||||
BindDN string `yaml:"bind_dn" env:"OCIS_LDAP_BIND_DN;GRAPH_LDAP_BIND_DN" desc:"LDAP DN to use for simple bind authentication with the target LDAP server." introductionVersion:"pre5.0"`
|
||||
BindPassword string `yaml:"bind_password" env:"OCIS_LDAP_BIND_PASSWORD;GRAPH_LDAP_BIND_PASSWORD" desc:"Password to use for authenticating the 'bind_dn'." introductionVersion:"pre5.0"`
|
||||
UseServerUUID bool `yaml:"use_server_uuid" env:"GRAPH_LDAP_SERVER_UUID" desc:"If set to true, rely on the LDAP Server to generate a unique ID for users and groups, like when using 'entryUUID' as the user ID attribute." introductionVersion:"pre5.0"`
|
||||
UsePasswordModExOp bool `yaml:"use_password_modify_exop" env:"GRAPH_LDAP_SERVER_USE_PASSWORD_MODIFY_EXOP" desc:"Use the 'Password Modify Extended Operation' for updating user passwords." introductionVersion:"pre5.0"`
|
||||
WriteEnabled bool `yaml:"write_enabled" env:"OCIS_LDAP_SERVER_WRITE_ENABLED;GRAPH_LDAP_SERVER_WRITE_ENABLED" desc:"Allow creating, modifying and deleting LDAP users via the GRAPH API. This can only be set to 'true' when keeping default settings for the LDAP user and group attribute types (the 'OCIS_LDAP_USER_SCHEMA_* and 'OCIS_LDAP_GROUP_SCHEMA_* variables)." introductionVersion:"pre5.0"`
|
||||
UpdateUserLastSignInDate bool `yaml:"update_user_last_sign_in_date" env:"OCIS_LDAP_UPDATE_LAST_SIGNIN_DATE;GRAPH_LDAP_UPDATE_LAST_SIGNIN_DATE" desc:"Update the 'oCLastSignInTimestamp' LDAP attribute of a user when the user signs in. The attribute is only persisted when 'OCIS_LDAP_SERVER_WRITE_ENABLED' is also enabled. Set this to 'false' to avoid an LDAP write on every sign-in, e.g. when the last sign-in timestamp is not needed or the LDAP write load should be reduced." introductionVersion:"8.0.6"`
|
||||
RetryMaxCount int `yaml:"retry_max_count" env:"OCIS_LDAP_RETRY_MAX_COUNT;GRAPH_LDAP_RETRY_MAX_COUNT" desc:"Maximum number of retries for failed LDAP operations. Reads retry on transient and network errors; writes retry only when the connection failed before the request was sent (e.g. a reused idle connection found closed), so the request provably never reached the server and cannot be double-applied. Default 1." introductionVersion:"8.2.0"`
|
||||
RetryBaseDelay time.Duration `yaml:"retry_base_delay" env:"OCIS_LDAP_RETRY_BASE_DELAY;GRAPH_LDAP_RETRY_BASE_DELAY" desc:"Base delay for exponential backoff between LDAP retries (e.g. '100ms'). Set to 0 to disable backoff." introductionVersion:"8.2.0"`
|
||||
RetryMaxDelay time.Duration `yaml:"retry_max_delay" env:"OCIS_LDAP_RETRY_MAX_DELAY;GRAPH_LDAP_RETRY_MAX_DELAY" desc:"Maximum delay cap for exponential backoff between LDAP retries (e.g. '5s'). 0 (default) uses the library default cap of 60s." introductionVersion:"8.2.0"`
|
||||
@@ -115,6 +117,7 @@ type LDAP struct {
|
||||
InstanceMapperIDAttribute string `yaml:"instance_mapper_id_attribute" env:"OCIS_LDAP_INSTANCE_MAPPER_ID_ATTRIBUTE" desc:"LDAP Attribute of the instance ID. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.0.0"`
|
||||
CrossInstanceReferenceTemplate string `yaml:"cross_instance_reference_template" env:"OCIS_LDAP_CROSS_INSTANCE_REFERENCE_TEMPLATE" desc:"Template for the users unique reference across oCIS instances. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.0.0"`
|
||||
InstanceURLTemplate string `yaml:"instance_url_template" env:"OCIS_LDAP_INSTANCE_URL_TEMPLATE" desc:"Template for the instance URL. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.0.0"`
|
||||
InstanceMapperCacheTTL int `yaml:"instance_mapper_cache_ttl" env:"OCIS_LDAP_INSTANCE_MAPPER_CACHE_TTL" desc:"Max TTL in seconds for the LDAP instance mapper cache. Requires OCIS_MULTI_INSTANCE_ENABLED." introductionVersion:"8.3.0"`
|
||||
}
|
||||
|
||||
// LDAPEducationConfig represents the LDAP configuration for education related resources
|
||||
|
||||
@@ -118,6 +118,8 @@ func DefaultConfig() *config.Config {
|
||||
GroupMemberAttribute: "member",
|
||||
GroupIDAttribute: "owncloudUUID",
|
||||
EducationResourcesEnabled: false,
|
||||
// 1 minute
|
||||
InstanceMapperCacheTTL: 60,
|
||||
},
|
||||
},
|
||||
Cache: &config.Cache{
|
||||
@@ -131,7 +133,8 @@ func DefaultConfig() *config.Config {
|
||||
Cluster: "ocis-cluster",
|
||||
EnableTLS: false,
|
||||
},
|
||||
MaxConcurrency: 20,
|
||||
MaxConcurrency: 20,
|
||||
ReceivedSharesStatTimeout: 10 * time.Second,
|
||||
UnifiedRoles: config.UnifiedRoles{
|
||||
AvailableRoles: nil, // will be populated with defaults in EnsureDefaults
|
||||
},
|
||||
@@ -218,4 +221,5 @@ func Sanitize(cfg *config.Config) {
|
||||
cfg.Spaces.ExtendedSpacePropertiesCacheTTL = cfg.Spaces.ExtendedSpacePropertiesCacheTTL * int(time.Second)
|
||||
cfg.Spaces.GroupsCacheTTL = cfg.Spaces.GroupsCacheTTL * int(time.Second)
|
||||
cfg.Spaces.UsersCacheTTL = cfg.Spaces.UsersCacheTTL * int(time.Second)
|
||||
cfg.Identity.LDAP.InstanceMapperCacheTTL = cfg.Identity.LDAP.InstanceMapperCacheTTL * int(time.Second)
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
backoff "github.com/cenkalti/backoff/v5"
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jellydator/ttlcache/v3"
|
||||
"github.com/libregraph/idm/pkg/ldapdn"
|
||||
libregraph "github.com/owncloud/libre-graph-api-go"
|
||||
|
||||
@@ -69,14 +70,14 @@ type LDAP struct {
|
||||
disableUserMechanism DisableUserMechanismType
|
||||
localUserDisableGroupDN string
|
||||
|
||||
groupBaseDN string
|
||||
groupCreateBaseDN string
|
||||
groupFilter string
|
||||
groupObjectClass string
|
||||
groupAdditionalObjectClasses []string
|
||||
groupIDisOctetString bool
|
||||
groupScope int
|
||||
groupAttributeMap groupAttributeMap
|
||||
groupBaseDN string
|
||||
groupCreateBaseDN string
|
||||
groupFilter string
|
||||
groupObjectClass string
|
||||
groupAdditionalObjectClasses []string
|
||||
groupIDisOctetString bool
|
||||
groupScope int
|
||||
groupAttributeMap groupAttributeMap
|
||||
|
||||
educationConfig educationConfig
|
||||
|
||||
@@ -94,8 +95,19 @@ type LDAP struct {
|
||||
instanceMapperIDAttribute string
|
||||
crossInstanceReferenceTemplate *template.Template
|
||||
instanceURLTemplate *template.Template
|
||||
instanceCache *ttlcache.Cache[string, string]
|
||||
}
|
||||
|
||||
// instanceCacheKeySep separates the fields of an instanceCache key. A NUL byte can't
|
||||
// appear in an LDAP attribute name or search value, so it can't cause key collisions
|
||||
// between different (searchAttribute, resultAttribute, searchValue) triples.
|
||||
const instanceCacheKeySep = "\x00"
|
||||
|
||||
// instanceCacheNotFound is stored in instanceCache to negatively cache a lookup
|
||||
// that resolved to ErrNotFound, so repeatedly requested stale instance references
|
||||
// don't cost a fresh LDAP round-trip on every call.
|
||||
const instanceCacheNotFound = instanceCacheKeySep + "not-found"
|
||||
|
||||
type userAttributeMap struct {
|
||||
displayName string
|
||||
id string
|
||||
@@ -205,6 +217,12 @@ func NewLDAPBackend(lc ldap.Client, config config.LDAP, logger *log.Logger, inst
|
||||
}
|
||||
}
|
||||
|
||||
instanceCache := ttlcache.New(
|
||||
ttlcache.WithTTL[string, string](time.Duration(config.InstanceMapperCacheTTL)),
|
||||
ttlcache.WithDisableTouchOnHit[string, string](),
|
||||
)
|
||||
go instanceCache.Start()
|
||||
|
||||
return &LDAP{
|
||||
useServerUUID: config.UseServerUUID,
|
||||
usePwModifyExOp: config.UsePasswordModExOp,
|
||||
@@ -241,6 +259,7 @@ func NewLDAPBackend(lc ldap.Client, config config.LDAP, logger *log.Logger, inst
|
||||
instanceMapperIDAttribute: config.InstanceMapperIDAttribute,
|
||||
crossInstanceReferenceTemplate: crossInstanceReferenceTemplate,
|
||||
instanceURLTemplate: instanceURLTemplate,
|
||||
instanceCache: instanceCache,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -1604,6 +1623,14 @@ func (i *LDAP) getInstance(searchValue, searchAttribute, resultAttribute string)
|
||||
return searchValue, nil
|
||||
}
|
||||
|
||||
cacheKey := searchAttribute + instanceCacheKeySep + resultAttribute + instanceCacheKeySep + searchValue
|
||||
if item := i.instanceCache.Get(cacheKey); item != nil {
|
||||
if item.Value() == instanceCacheNotFound {
|
||||
return "", ErrNotFound
|
||||
}
|
||||
return item.Value(), nil
|
||||
}
|
||||
|
||||
searchRequest := ldap.NewSearchRequest(
|
||||
i.instanceMapperBaseDN,
|
||||
ldap.ScopeWholeSubtree,
|
||||
@@ -1615,23 +1642,30 @@ func (i *LDAP) getInstance(searchValue, searchAttribute, resultAttribute string)
|
||||
|
||||
res, err := i.conn.Search(searchRequest)
|
||||
if err != nil {
|
||||
// Not cached: this is a transient LDAP failure, not a definitive answer.
|
||||
i.logger.Error().Err(err).Str("backend", "ldap").Str("dn", i.instanceMapperBaseDN).Str("searchValue", searchValue).Str("searchAttribute", searchAttribute).Str("resultAttribute", resultAttribute).Msg("Search instance failed")
|
||||
return "", errorcode.New(errorcode.ItemNotFound, "instanceid search failed")
|
||||
}
|
||||
if len(res.Entries) == 0 {
|
||||
// expected behaviour - we log debug in case something is fishy. This log can be removed when the feature proves stable
|
||||
i.logger.Debug().Str("backend", "ldap").Str("dn", i.instanceMapperBaseDN).Str("searchValue", searchValue).Interface("result", res).Msg("Search instance empty")
|
||||
i.instanceCache.Set(cacheKey, instanceCacheNotFound, ttlcache.DefaultTTL)
|
||||
return "", ErrNotFound
|
||||
}
|
||||
if len(res.Entries) > 1 {
|
||||
// Not cached: ambiguous data, don't freeze it in.
|
||||
i.logger.Error().Str("backend", "ldap").Str("dn", i.instanceMapperBaseDN).Str("searchValue", searchValue).Interface("result", res).Msg("Search instance returned multiple responses.")
|
||||
return "", errorcode.New(errorcode.ItemNotFound, "instanceid search returned multiple responses")
|
||||
}
|
||||
if len(res.Entries[0].Attributes) == 0 || len(res.Entries[0].Attributes[0].Values) == 0 {
|
||||
// Not cached: malformed data, don't freeze it in.
|
||||
i.logger.Error().Str("backend", "ldap").Str("dn", i.instanceMapperBaseDN).Str("searchValue", searchValue).Interface("result", res).Msg("Search instance returned malformed response")
|
||||
return "", errorcode.New(errorcode.ItemNotFound, "instanceid search response malformed")
|
||||
}
|
||||
return res.Entries[0].Attributes[0].Values[0], nil
|
||||
|
||||
value := res.Entries[0].Attributes[0].Values[0]
|
||||
i.instanceCache.Set(cacheKey, value, ttlcache.DefaultTTL)
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func (i *LDAP) getInstanceID(instancename string) (string, error) {
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package identity
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/config"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/identity/mocks"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
var instanceMapperConfig = config.LDAP{
|
||||
UserBaseDN: "ou=people,dc=test",
|
||||
UserObjectClass: "inetOrgPerson",
|
||||
UserSearchScope: "sub",
|
||||
UserDisplayNameAttribute: "displayname",
|
||||
UserIDAttribute: "entryUUID",
|
||||
UserEmailAttribute: "mail",
|
||||
UserNameAttribute: "uid",
|
||||
|
||||
GroupBaseDN: "ou=groups,dc=test",
|
||||
GroupObjectClass: "groupOfNames",
|
||||
GroupSearchScope: "sub",
|
||||
GroupNameAttribute: "cn",
|
||||
GroupMemberAttribute: "member",
|
||||
GroupIDAttribute: "entryUUID",
|
||||
|
||||
InstanceMapperEnabled: true,
|
||||
InstanceMapperBaseDN: "ou=instances,dc=test",
|
||||
InstanceMapperNameAttribute: "instanceName",
|
||||
InstanceMapperIDAttribute: "instanceID",
|
||||
}
|
||||
|
||||
func TestGetInstanceNameIsCached(t *testing.T) {
|
||||
lm := &mocks.Client{}
|
||||
b, err := getMockedBackend(lm, instanceMapperConfig, &logger)
|
||||
assert.Nil(t, err)
|
||||
|
||||
instanceEntry := ldap.NewEntry("instanceID=instance-1,ou=instances,dc=test",
|
||||
map[string][]string{
|
||||
"instanceName": {"Instance One"},
|
||||
})
|
||||
lm.On("Search", mock.Anything).
|
||||
Return(&ldap.SearchResult{Entries: []*ldap.Entry{instanceEntry}}, nil)
|
||||
|
||||
name1, err1 := b.getInstanceName("instance-1")
|
||||
assert.Nil(t, err1)
|
||||
assert.Equal(t, "Instance One", name1)
|
||||
|
||||
name2, err2 := b.getInstanceName("instance-1")
|
||||
assert.Nil(t, err2)
|
||||
assert.Equal(t, "Instance One", name2)
|
||||
|
||||
lm.AssertNumberOfCalls(t, "Search", 1)
|
||||
}
|
||||
|
||||
func TestGetInstanceNameCachesNotFound(t *testing.T) {
|
||||
lm := &mocks.Client{}
|
||||
b, err := getMockedBackend(lm, instanceMapperConfig, &logger)
|
||||
assert.Nil(t, err)
|
||||
|
||||
lm.On("Search", mock.Anything).
|
||||
Return(&ldap.SearchResult{Entries: []*ldap.Entry{}}, nil)
|
||||
|
||||
_, err1 := b.getInstanceName("stale-instance")
|
||||
assert.ErrorIs(t, err1, ErrNotFound)
|
||||
|
||||
_, err2 := b.getInstanceName("stale-instance")
|
||||
assert.ErrorIs(t, err2, ErrNotFound)
|
||||
|
||||
lm.AssertNumberOfCalls(t, "Search", 1)
|
||||
}
|
||||
@@ -167,7 +167,7 @@ func (api DriveItemPermissionsApi) CreateLink(w http.ResponseWriter, r *http.Req
|
||||
|
||||
var createLink libregraph.DriveItemCreateLink
|
||||
if err = StrictJSONUnmarshal(r.Body, &createLink); err != nil {
|
||||
logger.Error().Err(err).Interface("body", r.Body).Msg("could not create link: invalid body schema definition")
|
||||
logger.Error().Err(err).Msg("could not create link: invalid body schema definition")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
|
||||
return
|
||||
}
|
||||
@@ -196,7 +196,7 @@ func (api DriveItemPermissionsApi) CreateSpaceRootLink(w http.ResponseWriter, r
|
||||
|
||||
var createLink libregraph.DriveItemCreateLink
|
||||
if err = StrictJSONUnmarshal(r.Body, &createLink); err != nil {
|
||||
logger.Error().Err(err).Interface("body", r.Body).Msg("could not create link: invalid body schema definition")
|
||||
logger.Error().Err(err).Msg("could not create link: invalid body schema definition")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ func (g Graph) CreateAppRoleAssignment(w http.ResponseWriter, r *http.Request) {
|
||||
// DeleteAppRoleAssignment implements the Service interface.
|
||||
func (g Graph) DeleteAppRoleAssignment(w http.ResponseWriter, r *http.Request) {
|
||||
logger := g.logger.SubloggerWithRequestID(r.Context())
|
||||
logger.Info().Interface("body", r.Body).Msg("calling delete appRoleAssignment")
|
||||
logger.Info().Msg("calling delete appRoleAssignment")
|
||||
|
||||
userID := chi.URLParam(r, "userID")
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ func (g BaseGraphService) CS3ReceivedSharesToDriveItems(ctx context.Context, rec
|
||||
}
|
||||
|
||||
availableRoles := unifiedrole.GetRoles(unifiedrole.RoleFilterIDs(g.config.UnifiedRoles.AvailableRoles...))
|
||||
return cs3ReceivedSharesToDriveItems(ctx, g.logger, gatewayClient, g.identityCache, receivedShares, availableRoles)
|
||||
return cs3ReceivedSharesToDriveItems(ctx, g.logger, gatewayClient, g.identityCache, receivedShares, availableRoles, g.config.ReceivedSharesStatTimeout)
|
||||
}
|
||||
|
||||
func (g BaseGraphService) CS3ReceivedOCMSharesToDriveItems(ctx context.Context, receivedShares []*ocm.ReceivedShare) ([]libregraph.DriveItem, error) {
|
||||
|
||||
@@ -391,7 +391,7 @@ func (g Graph) createDrive(w http.ResponseWriter, r *http.Request, apiVersion AP
|
||||
|
||||
drive := libregraph.Drive{}
|
||||
if err := StrictJSONUnmarshal(r.Body, &drive); err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create drive: invalid body schema definition")
|
||||
logger.Debug().Err(err).Msg("could not create drive: invalid body schema definition")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
|
||||
return
|
||||
}
|
||||
@@ -524,7 +524,7 @@ func (g Graph) updateDrive(w http.ResponseWriter, r *http.Request, apiVersion AP
|
||||
|
||||
drive := libregraph.DriveUpdate{}
|
||||
if err = StrictJSONUnmarshal(r.Body, &drive); err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update drive, invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not update drive, invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: error: %v", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (g Graph) PostEducationClass(w http.ResponseWriter, r *http.Request) {
|
||||
class := libregraph.NewEducationClassWithDefaults()
|
||||
err := StrictJSONUnmarshal(r.Body, class)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create education class: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not create education class: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -110,7 +110,7 @@ func (g Graph) PatchEducationClass(w http.ResponseWriter, r *http.Request) {
|
||||
changes := libregraph.NewEducationClassWithDefaults()
|
||||
err = StrictJSONUnmarshal(r.Body, changes)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not change class: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not change class: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -315,10 +315,7 @@ func (g Graph) PostEducationClassMember(w http.ResponseWriter, r *http.Request)
|
||||
memberRef := libregraph.NewMemberReference()
|
||||
err = StrictJSONUnmarshal(r.Body, memberRef)
|
||||
if err != nil {
|
||||
logger.Debug().
|
||||
Err(err).
|
||||
Interface("body", r.Body).
|
||||
Msg("could not add class member: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not add class member: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -461,10 +458,7 @@ func (g Graph) PostEducationClassTeacher(w http.ResponseWriter, r *http.Request)
|
||||
memberRef := libregraph.NewMemberReference()
|
||||
err = StrictJSONUnmarshal(r.Body, memberRef)
|
||||
if err != nil {
|
||||
logger.Debug().
|
||||
Err(err).
|
||||
Interface("body", r.Body).
|
||||
Msg("could not add class teacher: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not add class teacher: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func (g Graph) PostEducationSchool(w http.ResponseWriter, r *http.Request) {
|
||||
school := libregraph.NewEducationSchool()
|
||||
err := StrictJSONUnmarshal(r.Body, school)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create school: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not create school: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func (g Graph) PatchEducationSchool(w http.ResponseWriter, r *http.Request) {
|
||||
school := libregraph.NewEducationSchool()
|
||||
err = StrictJSONUnmarshal(r.Body, school)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update school: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not update school: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -330,10 +330,7 @@ func (g Graph) PostEducationSchoolUser(w http.ResponseWriter, r *http.Request) {
|
||||
memberRef := libregraph.NewMemberReference()
|
||||
err = StrictJSONUnmarshal(r.Body, memberRef)
|
||||
if err != nil {
|
||||
logger.Debug().
|
||||
Err(err).
|
||||
Interface("body", r.Body).
|
||||
Msg("could not add school user: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not add school user: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -485,10 +482,7 @@ func (g Graph) PostEducationSchoolClass(w http.ResponseWriter, r *http.Request)
|
||||
memberRef := libregraph.NewMemberReference()
|
||||
err = StrictJSONUnmarshal(r.Body, memberRef)
|
||||
if err != nil {
|
||||
logger.Debug().
|
||||
Err(err).
|
||||
Interface("body", r.Body).
|
||||
Msg("could not add school class: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not add school class: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@ func (g Graph) GetEducationUsers(w http.ResponseWriter, r *http.Request) {
|
||||
// PostEducationUser implements the Service interface.
|
||||
func (g Graph) PostEducationUser(w http.ResponseWriter, r *http.Request) {
|
||||
logger := g.logger.SubloggerWithRequestID(r.Context())
|
||||
logger.Info().Interface("body", r.Body).Msg("calling create education user")
|
||||
logger.Info().Msg("calling create education user")
|
||||
u := libregraph.NewEducationUser()
|
||||
err := StrictJSONUnmarshal(r.Body, u)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create education user: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not create education user: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %v", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -321,7 +321,7 @@ func (g Graph) PatchEducationUser(w http.ResponseWriter, r *http.Request) {
|
||||
changes := libregraph.NewEducationUser()
|
||||
err = StrictJSONUnmarshal(r.Body, changes)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update education user: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not update education user: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
|
||||
fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
|
||||
@@ -99,7 +99,7 @@ func (g Graph) PostGroup(w http.ResponseWriter, r *http.Request) {
|
||||
grp := libregraph.NewGroup()
|
||||
err := StrictJSONUnmarshal(r.Body, grp)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not create group: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not create group: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
@@ -164,13 +164,13 @@ func (g Graph) PatchGroup(w http.ResponseWriter, r *http.Request) {
|
||||
changes := libregraph.NewGroup()
|
||||
err = StrictJSONUnmarshal(r.Body, changes)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not change group: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not change group: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if reflect.ValueOf(*changes).IsZero() {
|
||||
logger.Debug().Interface("body", r.Body).Msg("ignoring empyt request body")
|
||||
logger.Debug().Msg("ignoring empyt request body")
|
||||
render.Status(r, http.StatusNoContent)
|
||||
render.NoContent(w, r)
|
||||
return
|
||||
@@ -366,10 +366,7 @@ func (g Graph) PostGroupMember(w http.ResponseWriter, r *http.Request) {
|
||||
memberRef := libregraph.NewMemberReference()
|
||||
err = StrictJSONUnmarshal(r.Body, memberRef)
|
||||
if err != nil {
|
||||
logger.Debug().
|
||||
Err(err).
|
||||
Interface("body", r.Body).
|
||||
Msg("could not add group member: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not add group member: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func (g Graph) listSharedWithMe(ctx context.Context) ([]libregraph.DriveItem, er
|
||||
return nil, err
|
||||
}
|
||||
availableRoles := unifiedrole.GetRoles(unifiedrole.RoleFilterIDs(g.config.UnifiedRoles.AvailableRoles...))
|
||||
driveItems, err := cs3ReceivedSharesToDriveItems(ctx, g.logger, gatewayClient, g.identityCache, listReceivedSharesResponse.GetShares(), availableRoles)
|
||||
driveItems, err := cs3ReceivedSharesToDriveItems(ctx, g.logger, gatewayClient, g.identityCache, listReceivedSharesResponse.GetShares(), availableRoles, g.config.ReceivedSharesStatTimeout)
|
||||
if err != nil {
|
||||
g.logger.Error().Err(err).Msg("could not convert received shares to drive items")
|
||||
return nil, err
|
||||
|
||||
@@ -376,6 +376,157 @@ var _ = Describe("SharedWithMe", func() {
|
||||
Expect(jsonData.Get("id").String()).To(Equal(getUserResponseShareCreator.User.Id.OpaqueId))
|
||||
})
|
||||
|
||||
It("returns a degraded drive item when a share's resource stat times out", func() {
|
||||
// a second share, pointing at a different resource, whose Stat times out (transport error)
|
||||
brokenShare := &collaborationv1beta1.ReceivedShare{
|
||||
Share: &collaborationv1beta1.Share{
|
||||
ResourceId: toResourceID("7$8!9"),
|
||||
Id: &collaborationv1beta1.ShareId{
|
||||
OpaqueId: "broken:share:id",
|
||||
},
|
||||
Permissions: &collaborationv1beta1.SharePermissions{
|
||||
Permissions: roleconversions.NewViewerRole().CS3ResourcePermissions(),
|
||||
},
|
||||
Creator: getUserResponseShareCreator.User.Id,
|
||||
Ctime: utils.TSNow(),
|
||||
},
|
||||
MountPoint: &providerv1beta1.Reference{Path: "broken folder"},
|
||||
State: collaborationv1beta1.ShareState_SHARE_STATE_ACCEPTED,
|
||||
}
|
||||
listReceivedSharesResponse.Shares = append(listReceivedSharesResponse.Shares, brokenShare)
|
||||
|
||||
// reset and re-register the gateway expectations so Stat fails for the
|
||||
// broken share's resource but succeeds for the others.
|
||||
gatewayClient.ExpectedCalls = nil
|
||||
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(getUserResponseDefault, nil)
|
||||
gatewayClient.On("ListReceivedShares", mock.Anything, mock.Anything).Return(listReceivedSharesResponse, nil)
|
||||
gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(func(_ context.Context, r *providerv1beta1.StatRequest, _ ...grpc.CallOption) (*providerv1beta1.StatResponse, error) {
|
||||
if r.Ref.ResourceId == brokenShare.Share.ResourceId {
|
||||
return nil, context.DeadlineExceeded
|
||||
}
|
||||
return &providerv1beta1.StatResponse{
|
||||
Status: status.NewOK(ctx),
|
||||
Info: &providerv1beta1.ResourceInfo{
|
||||
Id: r.Ref.ResourceId,
|
||||
Type: providerv1beta1.ResourceType_RESOURCE_TYPE_CONTAINER,
|
||||
},
|
||||
}, nil
|
||||
})
|
||||
|
||||
svc.ListSharedWithMe(
|
||||
tape,
|
||||
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
|
||||
)
|
||||
|
||||
driveItems := libregraph.CollectionOfDriveItems{}
|
||||
err := json.Unmarshal(tape.Body.Bytes(), &driveItems)
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
// both shares must be present: the broken one is returned as a degraded
|
||||
// item built from the share record, not silently dropped.
|
||||
Expect(len(driveItems.Value)).To(Equal(2))
|
||||
|
||||
var remoteIDs []string
|
||||
for _, di := range driveItems.GetValue() {
|
||||
ri := di.GetRemoteItem()
|
||||
remoteIDs = append(remoteIDs, ri.GetId())
|
||||
}
|
||||
Expect(remoteIDs).To(ContainElement(storagespace.FormatResourceID(brokenShare.Share.ResourceId)))
|
||||
})
|
||||
|
||||
It("bounds the per-share Stat with the configured GRAPH_RECEIVED_SHARES_STAT_TIMEOUT", func() {
|
||||
// Use a value distinct from the 10s default so we can tell the
|
||||
// configured timeout (not the default) is the one applied. The service
|
||||
// holds cfg by pointer, so setting it here is observed by the handler.
|
||||
cfg.ReceivedSharesStatTimeout = 3 * time.Second
|
||||
|
||||
var statDeadline time.Time
|
||||
var statHadDeadline bool
|
||||
gatewayClient.ExpectedCalls = nil
|
||||
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(getUserResponseDefault, nil)
|
||||
gatewayClient.On("ListReceivedShares", mock.Anything, mock.Anything).Return(listReceivedSharesResponse, nil)
|
||||
gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(func(statCtx context.Context, r *providerv1beta1.StatRequest, _ ...grpc.CallOption) (*providerv1beta1.StatResponse, error) {
|
||||
// the worker writes these before returning; cs3ReceivedSharesToDriveItems
|
||||
// only returns after group.Wait(), so reading them after the handler
|
||||
// call is race-free.
|
||||
statDeadline, statHadDeadline = statCtx.Deadline()
|
||||
return &providerv1beta1.StatResponse{
|
||||
Status: status.NewOK(ctx),
|
||||
Info: &providerv1beta1.ResourceInfo{
|
||||
Id: r.Ref.ResourceId,
|
||||
Type: providerv1beta1.ResourceType_RESOURCE_TYPE_CONTAINER,
|
||||
},
|
||||
}, nil
|
||||
})
|
||||
|
||||
svc.ListSharedWithMe(
|
||||
tape,
|
||||
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
|
||||
)
|
||||
|
||||
Expect(tape.Code).To(Equal(http.StatusOK))
|
||||
// the per-share Stat must carry a deadline derived from the configured
|
||||
// timeout: never above the configured 3s, and clearly below the 10s default.
|
||||
Expect(statHadDeadline).To(BeTrue())
|
||||
Expect(time.Until(statDeadline)).To(BeNumerically("<=", 3*time.Second))
|
||||
Expect(time.Until(statDeadline)).To(BeNumerically(">", 2*time.Second))
|
||||
})
|
||||
|
||||
It("drops a share when the storage returns an error for its resource (e.g. the sharer was deleted)", func() {
|
||||
// a second share whose resource the storage cannot serve (definitive status error) must not be listed
|
||||
goneShare := &collaborationv1beta1.ReceivedShare{
|
||||
Share: &collaborationv1beta1.Share{
|
||||
ResourceId: toResourceID("7$8!9"),
|
||||
Id: &collaborationv1beta1.ShareId{
|
||||
OpaqueId: "gone:share:id",
|
||||
},
|
||||
Permissions: &collaborationv1beta1.SharePermissions{
|
||||
Permissions: roleconversions.NewViewerRole().CS3ResourcePermissions(),
|
||||
},
|
||||
Creator: getUserResponseShareCreator.User.Id,
|
||||
Ctime: utils.TSNow(),
|
||||
},
|
||||
MountPoint: &providerv1beta1.Reference{Path: "gone folder"},
|
||||
State: collaborationv1beta1.ShareState_SHARE_STATE_ACCEPTED,
|
||||
}
|
||||
listReceivedSharesResponse.Shares = append(listReceivedSharesResponse.Shares, goneShare)
|
||||
|
||||
gatewayClient.ExpectedCalls = nil
|
||||
gatewayClient.On("GetUser", mock.Anything, mock.Anything).Return(getUserResponseDefault, nil)
|
||||
gatewayClient.On("ListReceivedShares", mock.Anything, mock.Anything).Return(listReceivedSharesResponse, nil)
|
||||
gatewayClient.On("Stat", mock.Anything, mock.Anything).Return(func(_ context.Context, r *providerv1beta1.StatRequest, _ ...grpc.CallOption) (*providerv1beta1.StatResponse, error) {
|
||||
if r.Ref.ResourceId == goneShare.Share.ResourceId {
|
||||
return &providerv1beta1.StatResponse{Status: status.NewInternal(ctx, "node broken after sharer deletion")}, nil
|
||||
}
|
||||
return &providerv1beta1.StatResponse{
|
||||
Status: status.NewOK(ctx),
|
||||
Info: &providerv1beta1.ResourceInfo{
|
||||
Id: r.Ref.ResourceId,
|
||||
Type: providerv1beta1.ResourceType_RESOURCE_TYPE_CONTAINER,
|
||||
},
|
||||
}, nil
|
||||
})
|
||||
|
||||
svc.ListSharedWithMe(
|
||||
tape,
|
||||
httptest.NewRequest(http.MethodGet, "/graph/v1beta1/me/drive/sharedWithMe", nil),
|
||||
)
|
||||
|
||||
driveItems := libregraph.CollectionOfDriveItems{}
|
||||
err := json.Unmarshal(tape.Body.Bytes(), &driveItems)
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
// the dead share (resource gone) is dropped; only the healthy share remains
|
||||
Expect(len(driveItems.Value)).To(Equal(1))
|
||||
|
||||
var remoteIDs []string
|
||||
for _, di := range driveItems.GetValue() {
|
||||
ri := di.GetRemoteItem()
|
||||
remoteIDs = append(remoteIDs, ri.GetId())
|
||||
}
|
||||
Expect(remoteIDs).ToNot(ContainElement(storagespace.FormatResourceID(goneShare.Share.ResourceId)))
|
||||
})
|
||||
|
||||
It("returns a single drive item when multiple shares exist for the same resource", func() {
|
||||
anotherShare := &collaborationv1beta1.ReceivedShare{
|
||||
Share: &collaborationv1beta1.Share{
|
||||
|
||||
@@ -54,7 +54,7 @@ func (g Graph) AssignTags(w http.ResponseWriter, r *http.Request) {
|
||||
)
|
||||
|
||||
if err := StrictJSONUnmarshal(r.Body, &assignment); err != nil {
|
||||
g.logger.Debug().Err(err).Interface("body", r.Body).Msg("could not decode tag assignment request")
|
||||
g.logger.Debug().Err(err).Msg("could not decode tag assignment request")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
|
||||
return
|
||||
}
|
||||
@@ -161,7 +161,7 @@ func (g Graph) UnassignTags(w http.ResponseWriter, r *http.Request) {
|
||||
)
|
||||
|
||||
if err := StrictJSONUnmarshal(r.Body, &unassignment); err != nil {
|
||||
g.logger.Debug().Err(err).Interface("body", r.Body).Msg("could not decode tag assignment request")
|
||||
g.logger.Debug().Err(err).Msg("could not decode tag assignment request")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "invalid body schema definition")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -861,7 +861,7 @@ func (g Graph) PatchMe(w http.ResponseWriter, r *http.Request) {
|
||||
changes := libregraph.NewUserUpdate()
|
||||
err := StrictJSONUnmarshal(r.Body, changes)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update user: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not update user: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
|
||||
fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
@@ -893,7 +893,7 @@ func (g Graph) PatchUser(w http.ResponseWriter, r *http.Request) {
|
||||
changes := libregraph.NewUserUpdate()
|
||||
err = StrictJSONUnmarshal(r.Body, changes)
|
||||
if err != nil {
|
||||
logger.Debug().Err(err).Interface("body", r.Body).Msg("could not update user: invalid request body")
|
||||
logger.Debug().Err(err).Msg("could not update user: invalid request body")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest,
|
||||
fmt.Sprintf("invalid request body: %s", err.Error()))
|
||||
return
|
||||
@@ -934,7 +934,7 @@ func (g Graph) patchUser(w http.ResponseWriter, r *http.Request, nameOrID string
|
||||
}
|
||||
|
||||
if reflect.ValueOf(*changes).IsZero() {
|
||||
logger.Debug().Interface("body", r.Body).Msg("ignoring empty request body")
|
||||
logger.Debug().Msg("ignoring empty request body")
|
||||
render.Status(r, http.StatusNoContent)
|
||||
render.NoContent(w, r)
|
||||
return
|
||||
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"net/http"
|
||||
"path"
|
||||
"reflect"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
||||
cs3User "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
|
||||
@@ -170,18 +172,39 @@ func identitySetToSpacePermissionID(identitySet libregraph.SharePointIdentitySet
|
||||
return id
|
||||
}
|
||||
|
||||
// _receivedShareStatTimeout is the default bound for how long the resource Stat
|
||||
// for a single received share may take. It is used when the configured
|
||||
// GRAPH_RECEIVED_SHARES_STAT_TIMEOUT is not set (or non-positive). Without a
|
||||
// per-share bound, one slow or stuck downstream resource consumes the whole
|
||||
// request deadline budget, which causes the other shares to be dropped from the
|
||||
// sharedWithMe listing (and the request to occasionally 502). Keeping it small
|
||||
// relative to a typical request deadline lets one bad share fail fast without
|
||||
// affecting the visibility of the others.
|
||||
const _receivedShareStatTimeout = 10 * time.Second
|
||||
|
||||
func cs3ReceivedSharesToDriveItems(ctx context.Context,
|
||||
logger *log.Logger,
|
||||
gatewayClient gateway.GatewayAPIClient,
|
||||
identityCache identity.IdentityCache,
|
||||
receivedShares []*collaboration.ReceivedShare,
|
||||
availableRoles []*libregraph.UnifiedRoleDefinition,
|
||||
statTimeout time.Duration,
|
||||
) ([]libregraph.DriveItem, error) {
|
||||
|
||||
// Fall back to the default when unconfigured: a non-positive timeout would
|
||||
// make context.WithTimeout cancel immediately and drop every share.
|
||||
if statTimeout <= 0 {
|
||||
statTimeout = _receivedShareStatTimeout
|
||||
}
|
||||
|
||||
group := new(errgroup.Group)
|
||||
// Set max concurrency
|
||||
group.SetLimit(10)
|
||||
|
||||
// number of shares that could not be fully resolved and were returned as a
|
||||
// degraded drive item built from the share record alone.
|
||||
var degradedShares atomic.Int64
|
||||
|
||||
receivedSharesByResourceID := make(map[string][]*collaboration.ReceivedShare, len(receivedShares))
|
||||
for _, receivedShare := range receivedShares {
|
||||
if receivedShare == nil {
|
||||
@@ -197,18 +220,39 @@ func cs3ReceivedSharesToDriveItems(ctx context.Context,
|
||||
receivedShares := receivedSharesForResource
|
||||
|
||||
group.Go(func() error {
|
||||
var err error // redeclare
|
||||
shareStat, err := gatewayClient.Stat(ctx, &storageprovider.StatRequest{
|
||||
// Bound the per-share Stat so one slow/stuck resource cannot consume
|
||||
// the request deadline shared by all the other shares.
|
||||
statCtx, cancel := context.WithTimeout(ctx, statTimeout)
|
||||
defer cancel()
|
||||
shareStat, err := gatewayClient.Stat(statCtx, &storageprovider.StatRequest{
|
||||
Ref: &storageprovider.Reference{
|
||||
ResourceId: receivedShares[0].GetShare().GetResourceId(),
|
||||
},
|
||||
})
|
||||
|
||||
if err := errorcode.FromCS3Status(shareStat.GetStatus(), err); err != nil {
|
||||
logger.Debug().Err(err).
|
||||
if err != nil {
|
||||
// The storage could not be reached in time (per-share timeout,
|
||||
// cancellation, or an unavailable downstream). The resource most
|
||||
// likely still exists, so keep the share visible as a degraded item
|
||||
// built from the share record instead of dropping it: a single slow
|
||||
// share must neither vanish nor take the other shares down with it.
|
||||
logger.Warn().Err(err).
|
||||
Str("shareid", receivedShares[0].GetShare().GetId().GetOpaqueId()).
|
||||
Str("resourceid", storagespace.FormatResourceID(receivedShares[0].GetShare().GetResourceId())).
|
||||
Msg("could not stat received share, skipping")
|
||||
Msg("could not stat received share, returning a degraded drive item")
|
||||
degradedShares.Add(1)
|
||||
ch <- *buildDegradedDriveItemFromReceivedShares(ctx, logger, identityCache, receivedShares, availableRoles)
|
||||
return nil
|
||||
}
|
||||
|
||||
if statErr := errorcode.FromCS3Status(shareStat.GetStatus(), nil); statErr != nil {
|
||||
// The storage answered with a definitive error (resource gone,
|
||||
// access revoked, or a broken node, e.g. after the sharer was
|
||||
// deleted). The share is dead and must not be listed.
|
||||
logger.Debug().Err(statErr).
|
||||
Str("shareid", receivedShares[0].GetShare().GetId().GetOpaqueId()).
|
||||
Str("resourceid", storagespace.FormatResourceID(receivedShares[0].GetShare().GetResourceId())).
|
||||
Msg("could not stat received share, skipping (resource unavailable)")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -348,9 +392,68 @@ func cs3ReceivedSharesToDriveItems(ctx context.Context,
|
||||
driveItems = append(driveItems, di)
|
||||
}
|
||||
|
||||
if n := degradedShares.Load(); n > 0 {
|
||||
logger.Warn().
|
||||
Int64("degraded", n).
|
||||
Int("total", len(receivedSharesByResourceID)).
|
||||
Msg("some received shares could not be fully resolved and were returned as degraded drive items")
|
||||
}
|
||||
|
||||
return driveItems, err
|
||||
}
|
||||
|
||||
// buildDegradedDriveItemFromReceivedShares constructs a DriveItem for a set of
|
||||
// received shares pointing at the same resource when that resource could not be
|
||||
// statted. It exposes the data already contained in the share records (ids,
|
||||
// permissions, grantees, timestamps, mountpoint name) so the share stays
|
||||
// visible in the sharedWithMe listing instead of being silently dropped.
|
||||
// Properties that are only known from a successful Stat (size, etag, mime type,
|
||||
// owner, file/folder type) are intentionally left unset. It never returns an
|
||||
// error: if even the degraded build fails it falls back to a minimal item that
|
||||
// still carries the share identity.
|
||||
func buildDegradedDriveItemFromReceivedShares(ctx context.Context, logger *log.Logger,
|
||||
identityCache identity.IdentityCache, receivedShares []*collaboration.ReceivedShare,
|
||||
availableRoles []*libregraph.UnifiedRoleDefinition) *libregraph.DriveItem {
|
||||
|
||||
driveItem, err := fillDriveItemPropertiesFromReceivedShare(ctx, logger, identityCache, receivedShares, nil, availableRoles)
|
||||
if err != nil {
|
||||
logger.Warn().Err(err).
|
||||
Str("shareid", receivedShares[0].GetShare().GetId().GetOpaqueId()).
|
||||
Msg("could not build degraded drive item, returning a minimal item")
|
||||
driveItem = libregraph.NewDriveItem()
|
||||
driveItem.SetId(storagespace.FormatResourceID(&storageprovider.ResourceId{
|
||||
StorageId: utils.ShareStorageProviderID,
|
||||
OpaqueId: receivedShares[0].GetShare().GetId().GetOpaqueId(),
|
||||
SpaceId: utils.ShareStorageSpaceID,
|
||||
}))
|
||||
driveItem.RemoteItem = libregraph.NewRemoteItem()
|
||||
}
|
||||
|
||||
// the item lives in the virtual share jail, same as the fully-resolved item
|
||||
driveItem.ParentReference = libregraph.NewItemReference()
|
||||
driveItem.ParentReference.SetDriveType(_spaceTypeVirtual)
|
||||
driveItem.ParentReference.SetDriveId(storagespace.FormatStorageID(utils.ShareStorageProviderID, utils.ShareStorageSpaceID))
|
||||
driveItem.ParentReference.SetId(storagespace.FormatResourceID(&storageprovider.ResourceId{
|
||||
StorageId: utils.ShareStorageProviderID,
|
||||
OpaqueId: utils.ShareStorageSpaceID,
|
||||
SpaceId: utils.ShareStorageSpaceID,
|
||||
}))
|
||||
|
||||
if rid := receivedShares[0].GetShare().GetResourceId(); rid != nil {
|
||||
driveItem.RemoteItem.SetId(storagespace.FormatResourceID(rid))
|
||||
driveItem.RemoteItem.SpaceId = libregraph.PtrString(storagespace.FormatStorageID(rid.GetStorageId(), rid.GetSpaceId()))
|
||||
}
|
||||
|
||||
// fall back to the mountpoint name when the resource name is unknown
|
||||
if driveItem.GetName() == "" {
|
||||
if name := receivedShares[0].GetMountPoint().GetPath(); name != "" {
|
||||
driveItem.SetName(name)
|
||||
}
|
||||
}
|
||||
|
||||
return driveItem
|
||||
}
|
||||
|
||||
func fillDriveItemPropertiesFromReceivedShare(ctx context.Context, logger *log.Logger,
|
||||
identityCache identity.IdentityCache, receivedShares []*collaboration.ReceivedShare,
|
||||
resourceInfo *storageprovider.ResourceInfo, availableRoles []*libregraph.UnifiedRoleDefinition) (*libregraph.DriveItem, error) {
|
||||
@@ -443,26 +546,36 @@ func cs3ReceivedShareToLibreGraphPermissions(ctx context.Context, logger *log.Lo
|
||||
}
|
||||
|
||||
if permissionSet := receivedShare.GetShare().GetPermissions().GetPermissions(); permissionSet != nil {
|
||||
condition, err := roleConditionForResourceType(resourceInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// resourceInfo is nil for a degraded item, i.e. when the underlying
|
||||
// resource could not be statted. The resource type, and therefore the
|
||||
// unified role, cannot be determined in that case, so expose the raw
|
||||
// actions instead of failing the whole listing.
|
||||
if resourceInfo == nil {
|
||||
if actions := unifiedrole.CS3ResourcePermissionsToLibregraphActions(permissionSet); len(actions) > 0 {
|
||||
permission.SetLibreGraphPermissionsActions(actions)
|
||||
}
|
||||
} else {
|
||||
condition, err := roleConditionForResourceType(resourceInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
role := unifiedrole.CS3ResourcePermissionsToRole(
|
||||
availableRoles,
|
||||
permissionSet,
|
||||
condition,
|
||||
false,
|
||||
)
|
||||
if role != nil {
|
||||
permission.SetRoles([]string{role.GetId()})
|
||||
}
|
||||
role := unifiedrole.CS3ResourcePermissionsToRole(
|
||||
availableRoles,
|
||||
permissionSet,
|
||||
condition,
|
||||
false,
|
||||
)
|
||||
if role != nil {
|
||||
permission.SetRoles([]string{role.GetId()})
|
||||
}
|
||||
|
||||
actions := unifiedrole.CS3ResourcePermissionsToLibregraphActions(permissionSet)
|
||||
actions := unifiedrole.CS3ResourcePermissionsToLibregraphActions(permissionSet)
|
||||
|
||||
// actions only make sense if no role is set
|
||||
if role == nil && len(actions) > 0 {
|
||||
permission.SetLibreGraphPermissionsActions(actions)
|
||||
// actions only make sense if no role is set
|
||||
if role == nil && len(actions) > 0 {
|
||||
permission.SetLibreGraphPermissionsActions(actions)
|
||||
}
|
||||
}
|
||||
}
|
||||
switch grantee := receivedShare.GetShare().GetGrantee(); {
|
||||
|
||||
@@ -71,6 +71,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
ocdav.WebdavNamespace(cfg.WebdavNamespace),
|
||||
ocdav.OCMNamespace(cfg.OCMNamespace),
|
||||
ocdav.AllowDepthInfinity(cfg.AllowPropfindDepthInfinity),
|
||||
ocdav.DisablePropfindPublicLinkResolution(cfg.DisablePropfindPublicLinkResolution),
|
||||
ocdav.SharesNamespace(cfg.SharesNamespace),
|
||||
ocdav.Timeout(cfg.Timeout),
|
||||
ocdav.Insecure(cfg.Insecure),
|
||||
|
||||
@@ -38,6 +38,8 @@ type Config struct {
|
||||
Status Status `yaml:"-"`
|
||||
|
||||
AllowPropfindDepthInfinity bool `yaml:"allow_propfind_depth_infinity" env:"OCDAV_ALLOW_PROPFIND_DEPTH_INFINITY" desc:"Allow the use of depth infinity in PROPFINDS. When enabled, a propfind will traverse through all subfolders. If many subfolders are expected, depth infinity can cause heavy server load and/or delayed response times." introductionVersion:"pre5.0"`
|
||||
|
||||
DisablePropfindPublicLinkResolution bool `yaml:"disable_propfind_public_link_resolution" env:"OCDAV_DISABLE_PROPFIND_PUBLIC_LINK_RESOLUTION" desc:"Disable the resolution of public link shares when answering PROPFIND requests. When disabled, the oc:share-type property will not be populated with public link share information, which can reduce load on services for large collections." introductionVersion:"8.3.0"`
|
||||
}
|
||||
|
||||
type Log struct {
|
||||
|
||||
@@ -86,6 +86,7 @@ OPTIONS:
|
||||
--processing filter sessions by processing status (default: unset)
|
||||
--expired filter sessions by expired status (default: unset)
|
||||
--has-virus filter sessions by virus scan result (default: unset)
|
||||
--orphaned filter sessions by whether their node metadata is unreadable (default: unset)
|
||||
--json output as json (default: false)
|
||||
--restart send restart event for all listed sessions (default: false)
|
||||
--resume send resume event for all listed sessions (default: false)
|
||||
@@ -140,6 +141,23 @@ ocis storage-users uploads sessions --expired=true --clean
|
||||
ocis storage-users uploads sessions --processing=true --has-virus=false --resume
|
||||
```
|
||||
|
||||
Uploads whose node metadata can no longer be read are orphaned: they can never finish
|
||||
postprocessing, because the destination of the upload cannot be resolved. Such uploads stay
|
||||
in processing state indefinitely and keep consuming the quota of their space. Use the
|
||||
`--orphaned` filter to list them, and `--clean` to remove them and release the quota.
|
||||
|
||||
```bash
|
||||
# lists all orphaned upload sessions
|
||||
ocis storage-users uploads sessions --orphaned=true
|
||||
|
||||
# removes them and releases the quota they consume
|
||||
ocis storage-users uploads sessions --orphaned=true --clean
|
||||
```
|
||||
|
||||
Note: `--orphaned` reads the node metadata of every upload session, so it is slower than the
|
||||
other filters. Cleaning an orphaned session deletes the uploaded bytes, which are the only
|
||||
copy as long as postprocessing has not finished. Run the command without `--clean` first.
|
||||
|
||||
|
||||
#### Delete Stale Nodes command
|
||||
|
||||
@@ -184,6 +202,92 @@ ocis storage-users uploads delete-stale-nodes --dry-run=false --verbose
|
||||
```
|
||||
|
||||
|
||||
### Check and Inspect the Blobstore
|
||||
|
||||
The `blobstore` command group provides tools to verify connectivity to the configured blobstore and to inspect individual blobs. Both the `ocis` and `s3ng` storage drivers are supported.
|
||||
|
||||
```bash
|
||||
ocis storage-users blobstore <command>
|
||||
```
|
||||
|
||||
```plaintext
|
||||
COMMANDS:
|
||||
check check blobstore connectivity via an upload/download/delete round-trip
|
||||
get get a blob from the blobstore by ID
|
||||
```
|
||||
|
||||
#### Check
|
||||
|
||||
Verifies that the blobstore is reachable and fully operational by uploading a random blob, downloading and verifying it, then deleting it again. All three steps must succeed.
|
||||
|
||||
```bash
|
||||
ocis storage-users blobstore check [command options]
|
||||
```
|
||||
|
||||
```
|
||||
OPTIONS:
|
||||
--blob-size value size of the random blob to upload, e.g. 64, 1KB, 1MB, 4MiB (default: "64")
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
**Examples:**
|
||||
|
||||
```bash
|
||||
# Basic connectivity check using the default 64-byte payload
|
||||
ocis storage-users blobstore check
|
||||
|
||||
# Use a larger payload to also stress-test throughput
|
||||
ocis storage-users blobstore check --blob-size=4MiB
|
||||
```
|
||||
|
||||
```plaintext
|
||||
Uploading test blob: spaceID=a5c9bd5c-7348-4e9e-a462-d4d9e5287d01 blobID=3f1e5a82-b7e3-4c91-a110-1d5e2f3a4b6c
|
||||
Upload: OK
|
||||
Download and verify: OK
|
||||
Delete: OK
|
||||
Blobstore check successful.
|
||||
```
|
||||
|
||||
#### Get
|
||||
|
||||
Downloads a single blob by its ID to verify it exists and is readable. Useful when investigating errors in log lines that contain a blob path such as:
|
||||
|
||||
```
|
||||
decomposedfs: error download blob '04ba5496-...': blob path: b19ec764-.../61/03/ab/c3/-b08a-...: The specified key does not exist.
|
||||
```
|
||||
|
||||
The blob can be identified either by passing the raw path from the log line with `--path`, or by supplying `--blob-id` and `--space-id` individually.
|
||||
|
||||
```bash
|
||||
ocis storage-users blobstore get [command options]
|
||||
```
|
||||
|
||||
```
|
||||
OPTIONS:
|
||||
--path value blobstore path as it appears in log lines; spaceID and blobID are extracted automatically.
|
||||
Supports both s3ng format ("<spaceID>/<pathified_blobID>") and ocis format
|
||||
("…/spaces/<pathified_spaceID>/blobs/<pathified_blobID>").
|
||||
--blob-id value blob ID to download (required when --path is not set)
|
||||
--space-id value space ID the blob belongs to (required when --path is not set)
|
||||
--blob-size value expected blob size in bytes; only needed for the s3ng driver when the size is known
|
||||
upfront. If omitted or wrong, a size mismatch triggers one automatic retry with the
|
||||
actual size returned by s3ng. (default: 0)
|
||||
--help, -h show help
|
||||
```
|
||||
|
||||
**Examples:**
|
||||
|
||||
```bash
|
||||
# Identify a blob using the path from a log line (s3ng)
|
||||
ocis storage-users blobstore get --path="b19ec764-5398-458a-8ff1-1925bd906999/61/03/ab/c3/-b08a-4556-9937-2bf3065c1202"
|
||||
|
||||
# Identify a blob using the full filesystem path from a log line (ocis driver)
|
||||
ocis storage-users blobstore get --path="/var/lib/ocis/storage/users/spaces/b1/9ec764-5398-458a-8ff1-1925bd906999/blobs/61/03/ab/c3/-b08a-4556-9937-2bf3065c1202"
|
||||
|
||||
# Identify a blob using explicit IDs
|
||||
ocis storage-users blobstore get --space-id=b19ec764-5398-458a-8ff1-1925bd906999 --blob-id=6103abc3-b08a-4556-9937-2bf3065c1202
|
||||
```
|
||||
|
||||
### Manage Spaces
|
||||
|
||||
This command set provides commands to manage spaces, including purging disabled spaces that exceed the retention period.
|
||||
@@ -321,3 +425,106 @@ Store specific notes:
|
||||
- When using `redis-sentinel`, the Redis master to use is configured via e.g. `OCIS_CACHE_STORE_NODES` in the form of `<sentinel-host>:<sentinel-port>/<redis-master>` like `10.10.0.200:26379/mymaster`.
|
||||
- When using `nats-js-kv` it is recommended to set `OCIS_CACHE_STORE_NODES` to the same value as `OCIS_EVENTS_ENDPOINT`. That way the cache uses the same nats instance as the event bus.
|
||||
- When using the `nats-js-kv` store, it is possible to set `OCIS_CACHE_DISABLE_PERSISTENCE` to instruct nats to not persist cache data on disc.
|
||||
|
||||
## Vault Mode
|
||||
|
||||
Vault mode provides a dedicated, separately stored vault storage that can be MFA-protected. Vault resources are isolated from the default user storage and have their own search, shares, and spaces — while public links are explicitly disallowed.
|
||||
|
||||
### Architecture
|
||||
|
||||
* A dedicated `storage-users` vault storage instance is configured with a `VaultStorageProviderID` and mounted at `/vault/users` and `/vault/projects`.
|
||||
* The `graph` service API is extended to serve the `/vault` prefix when vault mode is active.
|
||||
* WebDAV access is supported for vault resources.
|
||||
* Search is scoped separately for default and vault files, including their shares and spaces.
|
||||
* Public links are disallowed for vault resources. The capabilities endpoint accepts a `vault=true` query parameter to advertise vault-specific capabilities.
|
||||
|
||||
#### The `vault mode` Configuration and Environment Variables
|
||||
|
||||
Set\
|
||||
`OCIS_MFA_ENABLED: true`\
|
||||
`OCIS_ENABLE_VAULT_MODE: true` and\
|
||||
to enable the vault mode in a OCIS.\
|
||||
Only applicapable if the storage-users-vault service, a special configured storage-users service is configured.
|
||||
|
||||
The storage-users-vault configuration:
|
||||
```
|
||||
STORAGE_USERS_SERVICE_NAME: storage-users-vault
|
||||
STORAGE_USERS_GRPC_ADDR: storage-users-vault:9285
|
||||
STORAGE_USERS_HTTP_ADDR: storage-users-vault:9286
|
||||
STORAGE_USERS_DATA_SERVER_URL: http://storage-users-vault:9286/data
|
||||
STORAGE_USERS_DEBUG_ADDR: storage-users-vault:9287
|
||||
STORAGE_USERS_OCIS_ROOT: /var/lib/ocis/storage/users-vault
|
||||
STORAGE_USERS_EVENTS_CONSUMER_GROUP: vault-dcfs
|
||||
```
|
||||
|
||||
```
|
||||
~/.ocis/storage
|
||||
$ tree users*
|
||||
users
|
||||
├── indexes
|
||||
│ ├── by-group-id
|
||||
│ ├── by-type
|
||||
│ │ └── personal.mpk
|
||||
│ └── by-user-id
|
||||
│ └── a032f2bd-fa5c-430b-a163-2c19f54190d0.mpk
|
||||
├── spaces
|
||||
│ └── a0
|
||||
│ └── 32f2bd-fa5c-430b-a163-2c19f54190d0
|
||||
│ └── nodes
|
||||
│ └── a0
|
||||
│ └── 32
|
||||
│ └── f2
|
||||
│ └── bd
|
||||
│ ├── -fa5c-430b-a163-2c19f54190d0
|
||||
│ ├── -fa5c-430b-a163-2c19f54190d0.mlock
|
||||
│ └── -fa5c-430b-a163-2c19f54190d0.mpk
|
||||
└── uploads
|
||||
users-vault
|
||||
├── indexes
|
||||
│ ├── by-group-id
|
||||
│ ├── by-type
|
||||
│ │ └── personal.mpk
|
||||
│ └── by-user-id
|
||||
│ └── a032f2bd-fa5c-430b-a163-2c19f54190d0.mpk
|
||||
├── spaces
|
||||
│ └── a0
|
||||
│ └── 32f2bd-fa5c-430b-a163-2c19f54190d0
|
||||
│ └── nodes
|
||||
│ └── a0
|
||||
│ └── 32
|
||||
│ └── f2
|
||||
│ └── bd
|
||||
│ ├── -fa5c-430b-a163-2c19f54190d0
|
||||
│ ├── -fa5c-430b-a163-2c19f54190d0.mlock
|
||||
│ └── -fa5c-430b-a163-2c19f54190d0.mpk
|
||||
└── uploads
|
||||
```
|
||||
|
||||
### Checking Vault Mode in the Frontend
|
||||
|
||||
To check whether vault mode is enabled in the frontend, use the `@ownclouders/web-pkg` package:
|
||||
|
||||
```typescript
|
||||
import { useAbility } from '@ownclouders/web-pkg'
|
||||
import { useCapabilityStore } from '@ownclouders/web-pkg'
|
||||
|
||||
const capabilityStore = useCapabilityStore()
|
||||
const { can } = useAbility()
|
||||
|
||||
const isVaultModeEnabled = capabilityStore.vaultEnabled && can('read-all', 'Vault')
|
||||
```
|
||||
|
||||
### Running with Docker
|
||||
|
||||
To enable vault mode in the `ocis_full` docker-compose stack, edit `deployments/examples/ocis_full/.env` and uncomment the following lines:
|
||||
|
||||
```.env
|
||||
KEYCLOAK=:keycloak.yml
|
||||
VAULT_STORAGE=:vault-storage.yml
|
||||
```
|
||||
|
||||
Then start the stack:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
@@ -93,6 +93,11 @@ func ListUploadSessions(cfg *config.Config) *cli.Command {
|
||||
DefaultText: "unset",
|
||||
Usage: "filter sessions by virus scan result",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "orphaned",
|
||||
DefaultText: "unset",
|
||||
Usage: "filter sessions by whether their node metadata is unreadable. Such sessions can never finish processing and can be removed with --clean",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "json",
|
||||
Usage: "output as json",
|
||||
@@ -259,6 +264,10 @@ func buildFilter(c *cli.Context) storage.UploadSessionFilter {
|
||||
infectedValue := c.Bool("has-virus")
|
||||
filter.HasVirus = &infectedValue
|
||||
}
|
||||
if c.IsSet("orphaned") {
|
||||
orphanedValue := c.Bool("orphaned")
|
||||
filter.Orphaned = &orphanedValue
|
||||
}
|
||||
if c.IsSet("id") {
|
||||
idValue := c.String("id")
|
||||
filter.ID = &idValue
|
||||
@@ -315,6 +324,24 @@ func buildInfo(filter storage.UploadSessionFilter) string {
|
||||
}
|
||||
}
|
||||
|
||||
if filter.Orphaned != nil {
|
||||
if b.Len() != 0 {
|
||||
b.WriteString(", ")
|
||||
}
|
||||
if !*filter.Orphaned {
|
||||
if b.Len() == 0 {
|
||||
b.WriteString("Not ")
|
||||
} else {
|
||||
b.WriteString("not ")
|
||||
}
|
||||
}
|
||||
if b.Len() == 0 {
|
||||
b.WriteString("Orphaned")
|
||||
} else {
|
||||
b.WriteString("orphaned")
|
||||
}
|
||||
}
|
||||
|
||||
if b.Len() == 0 {
|
||||
b.WriteString("Session")
|
||||
} else {
|
||||
|
||||
@@ -63,6 +63,26 @@ func TestBuildInfo(t *testing.T) {
|
||||
filter: storage.UploadSessionFilter{Processing: boolPtr(true), Expired: boolPtr(false), HasVirus: boolPtr(true), ID: strPtr("123")},
|
||||
expectedInfo: "Processing, not expired, virusinfected session with id '123':",
|
||||
},
|
||||
{
|
||||
alias: "orphaned",
|
||||
filter: storage.UploadSessionFilter{Orphaned: boolPtr(true)},
|
||||
expectedInfo: "Orphaned sessions:",
|
||||
},
|
||||
{
|
||||
alias: "not orphaned",
|
||||
filter: storage.UploadSessionFilter{Orphaned: boolPtr(false)},
|
||||
expectedInfo: "Not orphaned sessions:",
|
||||
},
|
||||
{
|
||||
alias: "processing and orphaned",
|
||||
filter: storage.UploadSessionFilter{Processing: boolPtr(true), Orphaned: boolPtr(true)},
|
||||
expectedInfo: "Processing, orphaned sessions:",
|
||||
},
|
||||
{
|
||||
alias: "expired, not virus infected and orphaned",
|
||||
filter: storage.UploadSessionFilter{Expired: boolPtr(true), HasVirus: boolPtr(false), Orphaned: boolPtr(true)},
|
||||
expectedInfo: "Expired, not virusinfected, orphaned sessions:",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
sonar.projectKey=owncloud_ocis
|
||||
sonar.organization=owncloud-1
|
||||
sonar.projectName=ocis
|
||||
sonar.projectVersion=8.0.7
|
||||
sonar.projectVersion=8.0.8
|
||||
sonar.host.url=https://sonarcloud.io
|
||||
|
||||
# =====================================================
|
||||
|
||||
+2
@@ -69,6 +69,8 @@ func (l *lineReader) Read(p []byte) (n int, err error) {
|
||||
if isPrefix {
|
||||
return 0, ArmorCorrupt
|
||||
}
|
||||
// Trim the line to remove any whitespace
|
||||
line = bytes.TrimSpace(line)
|
||||
|
||||
if bytes.HasPrefix(line, armorEnd) {
|
||||
l.eof = true
|
||||
|
||||
+10
@@ -180,6 +180,16 @@ func (dke ErrMalformedMessage) Error() string {
|
||||
return "openpgp: malformed message " + string(dke)
|
||||
}
|
||||
|
||||
type messageTooLargeError int
|
||||
|
||||
func (e messageTooLargeError) Error() string {
|
||||
return "openpgp: decompressed message size exceeds provided limit"
|
||||
}
|
||||
|
||||
// ErrMessageTooLarge is returned if the read data from
|
||||
// a compressed packet exceeds the provided limit.
|
||||
var ErrMessageTooLarge error = messageTooLargeError(0)
|
||||
|
||||
// ErrEncryptionKeySelection is returned if encryption key selection fails (v2 API).
|
||||
type ErrEncryptionKeySelection struct {
|
||||
PrimaryKeyId string
|
||||
|
||||
+8
-2
@@ -125,7 +125,10 @@ func (c *curve25519) Encaps(rand io.Reader, point []byte) (ephemeral, sharedSecr
|
||||
// "VB = convert point V to the octet string"
|
||||
// sharedPoint corresponds to `VB`.
|
||||
var sharedPoint x25519lib.Key
|
||||
x25519lib.Shared(&sharedPoint, &ephemeralPrivate, &pubKey)
|
||||
ok := x25519lib.Shared(&sharedPoint, &ephemeralPrivate, &pubKey)
|
||||
if !ok {
|
||||
return nil, nil, errors.KeyInvalidError("ecc: the public key is a low order point")
|
||||
}
|
||||
|
||||
return ephemeralPublic[:], sharedPoint[:], nil
|
||||
}
|
||||
@@ -146,7 +149,10 @@ func (c *curve25519) Decaps(vsG, secret []byte) (sharedSecret []byte, err error)
|
||||
// RFC6637 §8: "Note that the recipient obtains the shared secret by calculating
|
||||
// S = rV = rvG, where (r,R) is the recipient's key pair."
|
||||
// sharedPoint corresponds to `S`.
|
||||
x25519lib.Shared(&sharedPoint, &decodedPrivate, &ephemeralPublic)
|
||||
ok := x25519lib.Shared(&sharedPoint, &decodedPrivate, &ephemeralPublic)
|
||||
if !ok {
|
||||
return nil, errors.KeyInvalidError("ecc: the public key is a low order point")
|
||||
}
|
||||
|
||||
return sharedPoint[:], nil
|
||||
}
|
||||
|
||||
+4
-1
@@ -78,7 +78,7 @@ func (c *genericCurve) GenerateECDSA(rand io.Reader) (x, y, secret *big.Int, err
|
||||
func (c *genericCurve) Encaps(rand io.Reader, point []byte) (ephemeral, sharedSecret []byte, err error) {
|
||||
xP, yP := elliptic.Unmarshal(c.Curve, point)
|
||||
if xP == nil {
|
||||
panic("invalid point")
|
||||
return nil, nil, errors.KeyInvalidError(fmt.Sprintf("ecc (%s): invalid point", c.Curve.Params().Name))
|
||||
}
|
||||
|
||||
d, x, y, err := elliptic.GenerateKey(c.Curve, rand)
|
||||
@@ -99,6 +99,9 @@ func (c *genericCurve) Encaps(rand io.Reader, point []byte) (ephemeral, sharedSe
|
||||
|
||||
func (c *genericCurve) Decaps(ephemeral, secret []byte) (sharedSecret []byte, err error) {
|
||||
x, y := elliptic.Unmarshal(c.Curve, ephemeral)
|
||||
if x == nil {
|
||||
return nil, errors.KeyInvalidError(fmt.Sprintf("ecc (%s): invalid point", c.Curve.Params().Name))
|
||||
}
|
||||
zbBig, _ := c.Curve.ScalarMult(x, y, secret)
|
||||
byteLen := (c.Curve.Params().BitSize + 7) >> 3
|
||||
zb := make([]byte, byteLen)
|
||||
|
||||
+3
-3
@@ -37,7 +37,7 @@ func (conf *AEADConfig) Mode() AEADMode {
|
||||
|
||||
// ChunkSizeByte returns the byte indicating the chunk size. The effective
|
||||
// chunk size is computed with the formula uint64(1) << (chunkSizeByte + 6)
|
||||
// limit to 16 = 4 MiB
|
||||
// limit chunkSizeByte to 16 which equals to 2^22 = 4 MiB
|
||||
// https://www.ietf.org/archive/id/draft-ietf-openpgp-crypto-refresh-07.html#section-5.13.2
|
||||
func (conf *AEADConfig) ChunkSizeByte() byte {
|
||||
if conf == nil || conf.ChunkSize == 0 {
|
||||
@@ -49,8 +49,8 @@ func (conf *AEADConfig) ChunkSizeByte() byte {
|
||||
switch {
|
||||
case exponent < 6:
|
||||
exponent = 6
|
||||
case exponent > 16:
|
||||
exponent = 16
|
||||
case exponent > 22:
|
||||
exponent = 22
|
||||
}
|
||||
|
||||
return byte(exponent - 6)
|
||||
|
||||
+31
@@ -98,6 +98,16 @@ func (c *Compressed) parse(r io.Reader) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// LimitedBodyReader wraps the provided body reader with a limiter that restricts
|
||||
// the number of bytes read to the specified limit.
|
||||
// If limit is nil, the reader is unbounded.
|
||||
func (c *Compressed) LimitedBodyReader(limit *int64) io.Reader {
|
||||
if limit == nil {
|
||||
return c.Body
|
||||
}
|
||||
return &LimitReader{R: c.Body, N: *limit}
|
||||
}
|
||||
|
||||
// compressedWriterCloser represents the serialized compression stream
|
||||
// header and the compressor. Its Close() method ensures that both the
|
||||
// compressor and serialized stream header are closed. Its Write()
|
||||
@@ -159,3 +169,24 @@ func SerializeCompressed(w io.WriteCloser, algo CompressionAlgo, cc *Compression
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// LimitReader is an io.Reader that fails with MessageToLarge if read bytes exceed N.
|
||||
type LimitReader struct {
|
||||
R io.Reader // underlying reader
|
||||
N int64 // max bytes allowed
|
||||
}
|
||||
|
||||
func (l *LimitReader) Read(p []byte) (int, error) {
|
||||
if l.N <= 0 {
|
||||
return 0, errors.ErrMessageTooLarge
|
||||
}
|
||||
|
||||
n, err := l.R.Read(p)
|
||||
l.N -= int64(n)
|
||||
|
||||
if err == nil && l.N <= 0 {
|
||||
err = errors.ErrMessageTooLarge
|
||||
}
|
||||
|
||||
return n, err
|
||||
}
|
||||
+38
@@ -178,6 +178,23 @@ type Config struct {
|
||||
// When set to true, a key without flags is treated as if all flags are enabled.
|
||||
// This behavior is consistent with GPG.
|
||||
InsecureAllowAllKeyFlagsWhenMissing bool
|
||||
// InsecureGenerateNonCriticalKeyFlags causes the "Key Flags" signature subpacket
|
||||
// to be non-critical in newly generated signatures.
|
||||
// This may be needed for keys to be accepted by older clients who do not recognize
|
||||
// the subpacket.
|
||||
// For example, rpm 4.14.3-150400.59.3.1 in OpenSUSE Leap 15.4 does not recognize it.
|
||||
InsecureGenerateNonCriticalKeyFlags bool
|
||||
// InsecureGenerateNonCriticalSignatureCreationTime causes the "Signature Creation Time" signature subpacket
|
||||
// to be non-critical in newly generated signatures.
|
||||
// This may be needed for keys to be accepted by older clients who do not recognize
|
||||
// the subpacket.
|
||||
// For example, yum 3.4.3-168 in CentOS 7 and yum 3.4.3-158 in Amazon Linux 2 do not recognize it.
|
||||
InsecureGenerateNonCriticalSignatureCreationTime bool
|
||||
|
||||
// MaxDecompressedMessageSize specifies the maximum number of bytes that can be
|
||||
// read from a compressed packet. This serves as an upper limit to prevent
|
||||
// excessively large decompressed messages.
|
||||
MaxDecompressedMessageSize *int64
|
||||
}
|
||||
|
||||
func (c *Config) Random() io.Reader {
|
||||
@@ -415,6 +432,27 @@ func (c *Config) AllowAllKeyFlagsWhenMissing() bool {
|
||||
return c.InsecureAllowAllKeyFlagsWhenMissing
|
||||
}
|
||||
|
||||
func (c *Config) GenerateNonCriticalKeyFlags() bool {
|
||||
if c == nil {
|
||||
return false
|
||||
}
|
||||
return c.InsecureGenerateNonCriticalKeyFlags
|
||||
}
|
||||
|
||||
func (c *Config) GenerateNonCriticalSignatureCreationTime() bool {
|
||||
if c == nil {
|
||||
return false
|
||||
}
|
||||
return c.InsecureGenerateNonCriticalSignatureCreationTime
|
||||
}
|
||||
|
||||
func (c *Config) DecompressedMessageSizeLimit() *int64 {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
return c.MaxDecompressedMessageSize
|
||||
}
|
||||
|
||||
// BoolPointer is a helper function to set a boolean pointer in the Config.
|
||||
// e.g., config.CheckPacketSequence = BoolPointer(true)
|
||||
func BoolPointer(value bool) *bool {
|
||||
|
||||
+4
-4
@@ -933,7 +933,7 @@ func (sig *Signature) Sign(h hash.Hash, priv *PrivateKey, config *Config) (err e
|
||||
}
|
||||
sig.Notations = append(sig.Notations, ¬ation)
|
||||
}
|
||||
sig.outSubpackets, err = sig.buildSubpackets(priv.PublicKey)
|
||||
sig.outSubpackets, err = sig.buildSubpackets(priv.PublicKey, config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1254,11 +1254,11 @@ type outputSubpacket struct {
|
||||
contents []byte
|
||||
}
|
||||
|
||||
func (sig *Signature) buildSubpackets(issuer PublicKey) (subpackets []outputSubpacket, err error) {
|
||||
func (sig *Signature) buildSubpackets(issuer PublicKey, config *Config) (subpackets []outputSubpacket, err error) {
|
||||
creationTime := make([]byte, 4)
|
||||
binary.BigEndian.PutUint32(creationTime, uint32(sig.CreationTime.Unix()))
|
||||
// Signature Creation Time
|
||||
subpackets = append(subpackets, outputSubpacket{true, creationTimeSubpacket, true, creationTime})
|
||||
subpackets = append(subpackets, outputSubpacket{true, creationTimeSubpacket, !config.GenerateNonCriticalSignatureCreationTime(), creationTime})
|
||||
// Signature Expiration Time
|
||||
if sig.SigLifetimeSecs != nil && *sig.SigLifetimeSecs != 0 {
|
||||
sigLifetime := make([]byte, 4)
|
||||
@@ -1357,7 +1357,7 @@ func (sig *Signature) buildSubpackets(issuer PublicKey) (subpackets []outputSubp
|
||||
if sig.FlagGroupKey {
|
||||
flags |= KeyFlagGroupKey
|
||||
}
|
||||
subpackets = append(subpackets, outputSubpacket{true, keyFlagsSubpacket, true, []byte{flags}})
|
||||
subpackets = append(subpackets, outputSubpacket{true, keyFlagsSubpacket, !config.GenerateNonCriticalKeyFlags(), []byte{flags}})
|
||||
}
|
||||
// Signer's User ID
|
||||
if sig.SignerUserId != nil {
|
||||
|
||||
+1
-1
@@ -259,7 +259,7 @@ FindLiteralData:
|
||||
}
|
||||
switch p := p.(type) {
|
||||
case *packet.Compressed:
|
||||
if err := packets.Push(p.Body); err != nil {
|
||||
if err := packets.Push(p.LimitedBodyReader(config.DecompressedMessageSizeLimit())); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case *packet.OnePassSignature:
|
||||
|
||||
+97
-27
@@ -253,34 +253,12 @@ func writeAndSign(payload io.WriteCloser, candidateHashes []uint8, signed *Entit
|
||||
}
|
||||
|
||||
var hash crypto.Hash
|
||||
for _, hashId := range candidateHashes {
|
||||
if h, ok := algorithm.HashIdToHash(hashId); ok && h.Available() {
|
||||
hash = h
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// If the hash specified by config is a candidate, we'll use that.
|
||||
if configuredHash := config.Hash(); configuredHash.Available() {
|
||||
for _, hashId := range candidateHashes {
|
||||
if h, ok := algorithm.HashIdToHash(hashId); ok && h == configuredHash {
|
||||
hash = h
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if hash == 0 {
|
||||
hashId := candidateHashes[0]
|
||||
name, ok := algorithm.HashIdToString(hashId)
|
||||
if !ok {
|
||||
name = "#" + strconv.Itoa(int(hashId))
|
||||
}
|
||||
return nil, errors.InvalidArgumentError("cannot encrypt because no candidate hash functions are compiled in. (Wanted " + name + " in this case.)")
|
||||
}
|
||||
|
||||
var salt []byte
|
||||
if signer != nil {
|
||||
if hash, err = selectHash(candidateHashes, config.Hash(), signer); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var opsVersion = 3
|
||||
if signer.Version == 6 {
|
||||
opsVersion = signer.Version
|
||||
@@ -558,13 +536,34 @@ func (s signatureWriter) Close() error {
|
||||
return s.encryptedData.Close()
|
||||
}
|
||||
|
||||
func selectHashForSigningKey(config *packet.Config, signer *packet.PublicKey) crypto.Hash {
|
||||
acceptableHashes := acceptableHashesToWrite(signer)
|
||||
hash, ok := algorithm.HashToHashId(config.Hash())
|
||||
if !ok {
|
||||
return config.Hash()
|
||||
}
|
||||
for _, acceptableHashes := range acceptableHashes {
|
||||
if acceptableHashes == hash {
|
||||
return config.Hash()
|
||||
}
|
||||
}
|
||||
if len(acceptableHashes) > 0 {
|
||||
defaultAcceptedHash, ok := algorithm.HashIdToHash(acceptableHashes[0])
|
||||
if ok {
|
||||
return defaultAcceptedHash
|
||||
}
|
||||
}
|
||||
return config.Hash()
|
||||
}
|
||||
|
||||
func createSignaturePacket(signer *packet.PublicKey, sigType packet.SignatureType, config *packet.Config) *packet.Signature {
|
||||
sigLifetimeSecs := config.SigLifetime()
|
||||
hash := selectHashForSigningKey(config, signer)
|
||||
return &packet.Signature{
|
||||
Version: signer.Version,
|
||||
SigType: sigType,
|
||||
PubKeyAlgo: signer.PubKeyAlgo,
|
||||
Hash: config.Hash(),
|
||||
Hash: hash,
|
||||
CreationTime: config.Now(),
|
||||
IssuerKeyId: &signer.KeyId,
|
||||
IssuerFingerprint: signer.Fingerprint,
|
||||
@@ -618,3 +617,74 @@ func handleCompression(compressed io.WriteCloser, candidateCompression []uint8,
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// selectHash selects the preferred hash given the candidateHashes and the configuredHash
|
||||
func selectHash(candidateHashes []byte, configuredHash crypto.Hash, signer *packet.PrivateKey) (hash crypto.Hash, err error) {
|
||||
acceptableHashes := acceptableHashesToWrite(&signer.PublicKey)
|
||||
candidateHashes = intersectPreferences(acceptableHashes, candidateHashes)
|
||||
|
||||
for _, hashId := range candidateHashes {
|
||||
if h, ok := algorithm.HashIdToHash(hashId); ok && h.Available() {
|
||||
hash = h
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// If the hash specified by config is a candidate, we'll use that.
|
||||
if configuredHash.Available() {
|
||||
for _, hashId := range candidateHashes {
|
||||
if h, ok := algorithm.HashIdToHash(hashId); ok && h == configuredHash {
|
||||
hash = h
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if hash == 0 {
|
||||
if len(acceptableHashes) > 0 {
|
||||
if h, ok := algorithm.HashIdToHash(acceptableHashes[0]); ok {
|
||||
hash = h
|
||||
} else {
|
||||
return 0, errors.UnsupportedError("no candidate hash functions are compiled in.")
|
||||
}
|
||||
} else {
|
||||
return 0, errors.UnsupportedError("no candidate hash functions are compiled in.")
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func acceptableHashesToWrite(singingKey *packet.PublicKey) []uint8 {
|
||||
switch singingKey.PubKeyAlgo {
|
||||
case packet.PubKeyAlgoEd448:
|
||||
return []uint8{
|
||||
hashToHashId(crypto.SHA512),
|
||||
hashToHashId(crypto.SHA3_512),
|
||||
}
|
||||
case packet.PubKeyAlgoECDSA, packet.PubKeyAlgoEdDSA:
|
||||
if curve, err := singingKey.Curve(); err == nil {
|
||||
if curve == packet.Curve448 ||
|
||||
curve == packet.CurveNistP521 ||
|
||||
curve == packet.CurveBrainpoolP512 {
|
||||
return []uint8{
|
||||
hashToHashId(crypto.SHA512),
|
||||
hashToHashId(crypto.SHA3_512),
|
||||
}
|
||||
} else if curve == packet.CurveBrainpoolP384 ||
|
||||
curve == packet.CurveNistP384 {
|
||||
return []uint8{
|
||||
hashToHashId(crypto.SHA384),
|
||||
hashToHashId(crypto.SHA512),
|
||||
hashToHashId(crypto.SHA3_512),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return []uint8{
|
||||
hashToHashId(crypto.SHA256),
|
||||
hashToHashId(crypto.SHA384),
|
||||
hashToHashId(crypto.SHA512),
|
||||
hashToHashId(crypto.SHA3_256),
|
||||
hashToHashId(crypto.SHA3_512),
|
||||
}
|
||||
}
|
||||
+6
@@ -61,6 +61,9 @@ func (Curve) Double(P *Point) *Point { R := *P; R.Double(); return &R }
|
||||
func (Curve) Add(P, Q *Point) *Point { R := *P; R.Add(Q); return &R }
|
||||
|
||||
// ScalarMult returns kP. This function runs in constant time.
|
||||
//
|
||||
// The result equals [k]P only when P is in the prime-order subgroup; any
|
||||
// torsion component of P is dropped.
|
||||
func (e Curve) ScalarMult(k *Scalar, P *Point) *Point {
|
||||
k4 := &Scalar{}
|
||||
k4.divBy4(k)
|
||||
@@ -75,6 +78,9 @@ func (e Curve) ScalarBaseMult(k *Scalar) *Point {
|
||||
}
|
||||
|
||||
// CombinedMult returns mG+nP, where G is the generator point. This function is non-constant time.
|
||||
//
|
||||
// Like ScalarMult, the result equals [m]G+[n]P only when P is in the
|
||||
// prime-order subgroup; any torsion component of P is dropped.
|
||||
func (e Curve) CombinedMult(m, n *Scalar, P *Point) *Point {
|
||||
m4 := &Scalar{}
|
||||
n4 := &Scalar{}
|
||||
|
||||
+11
-1
@@ -46,6 +46,9 @@ func FromBytes(in []byte) (*Point, error) {
|
||||
}
|
||||
err := errors.New("invalid decoding")
|
||||
P := &Point{}
|
||||
if in[fp.Size]&0x7F != 0 {
|
||||
return nil, err
|
||||
}
|
||||
signX := in[fp.Size] >> 7
|
||||
copy(P.y[:], in[:fp.Size])
|
||||
p := fp.P()
|
||||
@@ -135,7 +138,14 @@ func (P *Point) MarshalBinary() (data []byte, err error) {
|
||||
}
|
||||
|
||||
// UnmarshalBinary must be able to decode the form generated by MarshalBinary.
|
||||
func (P *Point) UnmarshalBinary(data []byte) error { Q, err := FromBytes(data); *P = *Q; return err }
|
||||
func (P *Point) UnmarshalBinary(data []byte) error {
|
||||
Q, err := FromBytes(data)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*P = *Q
|
||||
return nil
|
||||
}
|
||||
|
||||
// Double sets P = 2Q.
|
||||
func (P *Point) Double() { P.Add(P) }
|
||||
|
||||
+35
-12
@@ -9,9 +9,6 @@ package mlsbset
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/cloudflare/circl/internal/conv"
|
||||
)
|
||||
|
||||
// EltG is a group element.
|
||||
@@ -69,17 +66,43 @@ func (m Encoder) Encode(k []byte) (*Power, error) {
|
||||
k = append(k, make([]byte, ap)...)
|
||||
s := m.signs(k)
|
||||
b := make([]int32, m.p.L-m.p.D)
|
||||
c := conv.BytesLe2BigInt(k)
|
||||
c.Rsh(c, m.p.D)
|
||||
var bi big.Int
|
||||
|
||||
// Original algorithm starts with c := k >> D, then computes
|
||||
//
|
||||
// b_(i-D) = s_(i%D) * lsb(c)
|
||||
// c = [ (c>>1)+1 if b_(i-D) = -1
|
||||
// [ c>>1 otherwise
|
||||
//
|
||||
// To prevent keeping a large k around, we note that at any step i we have
|
||||
//
|
||||
// c = (k >> i) + t for t in {0,1}
|
||||
//
|
||||
// Base case is obvious. For induction, write kbit for the i-th bit of k.
|
||||
// Note lsb(c) = kbit ^ t. From that we can compute b_(i-D). Now we need
|
||||
// to compute the next t.
|
||||
//
|
||||
// Consider c >> 1 = (k >> i) + t) >> 1. This equals k >> (i+1)
|
||||
// unless t = 1 = kbit.
|
||||
//
|
||||
// If b_(i-D) is negative, then we must have had 1=lsb(c)=kbit^t, and so
|
||||
// c >> 1 = k >> (i+1), as desired with new t equal to 1.
|
||||
// For the other case assume b_(i-D) isn't negative. Now it is possible
|
||||
// that t = 1 = kbit, and only in that case the new t is equal to 1.
|
||||
var t uint64
|
||||
for i := m.p.D; i < m.p.L; i++ {
|
||||
c0 := int32(c.Bit(0))
|
||||
b[i-m.p.D] = s[i%m.p.D] * c0
|
||||
bi.SetInt64(int64(b[i-m.p.D] >> 1))
|
||||
c.Rsh(c, 1)
|
||||
c.Sub(c, &bi)
|
||||
si := s[i%m.p.D]
|
||||
kbit := uint64(k[i>>3]>>(i&7)) & 1
|
||||
lsbc := kbit ^ t
|
||||
neg := uint64(si>>31) & 1 // 1 iff si == -1
|
||||
b[i-m.p.D] = si * int32(lsbc)
|
||||
t = (kbit & t) | (lsbc & neg)
|
||||
}
|
||||
// carry = (k >> L) + t: any bits of k at positions >= L (present when L is
|
||||
// not a multiple of 8) plus the final carry, matching the original.
|
||||
carry := int(t)
|
||||
for pos := m.p.L; int(pos>>3) < len(k); pos++ {
|
||||
carry += int((k[pos>>3]>>(pos&7))&1) << (pos - m.p.L)
|
||||
}
|
||||
carry := int(c.Int64())
|
||||
return &Power{m, s, b, carry}, nil
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -1,7 +1,7 @@
|
||||
// Package ed25519 implements Ed25519 signature scheme as described in RFC-8032.
|
||||
//
|
||||
// This package provides optimized implementations of the three signature
|
||||
// variants and maintaining closer compatibility with crypto/ed25519.
|
||||
// variants and maintaining almost full compatibility with crypto/ed25519.
|
||||
//
|
||||
// | Scheme Name | Sign Function | Verification | Context |
|
||||
// |-------------|-------------------|---------------|-------------------|
|
||||
@@ -28,6 +28,13 @@
|
||||
// operations with the same key more efficient. This package refers to the
|
||||
// RFC-8032 private key as the “seed”.
|
||||
//
|
||||
// Public keys are decoded following RFC 8032 strictly: an encoding whose
|
||||
// y-coordinate is not reduced modulo 2^255-19, or whose x-coordinate is zero
|
||||
// with the sign bit set, is rejected. crypto/ed25519 accepts those
|
||||
// non-canonical encodings instead, so for a small, fixed set of malformed
|
||||
// public keys the verification functions here return false where
|
||||
// crypto/ed25519 returns true.
|
||||
//
|
||||
// References
|
||||
//
|
||||
// - RFC-8032: https://rfc-editor.org/rfc/rfc8032.txt
|
||||
|
||||
+4
-2
@@ -69,7 +69,8 @@ func (*scheme) DeriveKey(seed []byte) (sign.PublicKey, sign.PrivateKey) {
|
||||
}
|
||||
|
||||
func (*scheme) UnmarshalBinaryPublicKey(buf []byte) (sign.PublicKey, error) {
|
||||
if len(buf) < PublicKeySize {
|
||||
// NOTE Old version of CIRCL accepted trailing data.
|
||||
if len(buf) != PublicKeySize {
|
||||
return nil, sign.ErrPubKeySize
|
||||
}
|
||||
pub := make(PublicKey, PublicKeySize)
|
||||
@@ -78,7 +79,8 @@ func (*scheme) UnmarshalBinaryPublicKey(buf []byte) (sign.PublicKey, error) {
|
||||
}
|
||||
|
||||
func (*scheme) UnmarshalBinaryPrivateKey(buf []byte) (sign.PrivateKey, error) {
|
||||
if len(buf) < PrivateKeySize {
|
||||
// NOTE Old version of CIRCL accepted trailing data.
|
||||
if len(buf) != PrivateKeySize {
|
||||
return nil, sign.ErrPrivKeySize
|
||||
}
|
||||
priv := make(PrivateKey, PrivateKeySize)
|
||||
|
||||
+6
@@ -345,6 +345,8 @@ func verify(public PublicKey, message, signature, ctx []byte, preHash bool) bool
|
||||
// The opts.HashFunc() must return zero, this can be achieved by passing
|
||||
// crypto.Hash(0) as the value for opts.
|
||||
// Use a SignerOptions struct to pass a context string for signing.
|
||||
//
|
||||
// Uses the default RFC 8032 cofactor-clearing verification.
|
||||
func VerifyAny(public PublicKey, message, signature []byte, opts crypto.SignerOpts) bool {
|
||||
var ctx string
|
||||
var scheme SchemeID
|
||||
@@ -367,6 +369,8 @@ func VerifyAny(public PublicKey, message, signature []byte, opts crypto.SignerOp
|
||||
// signature, or when the public key cannot be decoded.
|
||||
// This function supports the signature variant defined in RFC-8032: Ed448,
|
||||
// also known as the pure version of EdDSA.
|
||||
//
|
||||
// Uses the default RFC 8032 cofactor-clearing verification.
|
||||
func Verify(public PublicKey, message, signature []byte, ctx string) bool {
|
||||
return verify(public, message, signature, []byte(ctx), false)
|
||||
}
|
||||
@@ -377,6 +381,8 @@ func Verify(public PublicKey, message, signature []byte, ctx string) bool {
|
||||
// meaning it internally hashes the message using SHAKE-256.
|
||||
// Context could be passed to this function, which length should be no more than
|
||||
// 255. It can be empty.
|
||||
//
|
||||
// Uses the default RFC 8032 cofactor-clearing verification.
|
||||
func VerifyPh(public PublicKey, message, signature []byte, ctx string) bool {
|
||||
return verify(public, message, signature, []byte(ctx), true)
|
||||
}
|
||||
|
||||
+4
-2
@@ -69,7 +69,8 @@ func (*scheme) DeriveKey(seed []byte) (sign.PublicKey, sign.PrivateKey) {
|
||||
}
|
||||
|
||||
func (*scheme) UnmarshalBinaryPublicKey(buf []byte) (sign.PublicKey, error) {
|
||||
if len(buf) < PublicKeySize {
|
||||
// NOTE Old version of CIRCL accepted trailing data.
|
||||
if len(buf) != PublicKeySize {
|
||||
return nil, sign.ErrPubKeySize
|
||||
}
|
||||
pub := make(PublicKey, PublicKeySize)
|
||||
@@ -78,7 +79,8 @@ func (*scheme) UnmarshalBinaryPublicKey(buf []byte) (sign.PublicKey, error) {
|
||||
}
|
||||
|
||||
func (*scheme) UnmarshalBinaryPrivateKey(buf []byte) (sign.PrivateKey, error) {
|
||||
if len(buf) < PrivateKeySize {
|
||||
// NOTE Old version of CIRCL accepted trailing data.
|
||||
if len(buf) != PrivateKeySize {
|
||||
return nil, sign.ErrPrivKeySize
|
||||
}
|
||||
priv := make(PrivateKey, PrivateKeySize)
|
||||
|
||||
+11
@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [Unreleased] ##
|
||||
|
||||
## [0.7.0] - 2025-06-17 ##
|
||||
|
||||
> You talk of times of peace for all, and then prepare for war.
|
||||
|
||||
### Changed ###
|
||||
- Update to `cyphar.com/go-pathrs@0.2.5`, which included a build-time API
|
||||
breakage that we needed to work around. The API of this library is unchanged
|
||||
by this, but users should make sure to update to `v0.7.0` of
|
||||
`filepath-securejoin` if they use the `libpathrs` built tag and have update
|
||||
to `libpathrs` `v0.2.5`.
|
||||
|
||||
## [0.6.1] - 2025-11-19 ##
|
||||
|
||||
> At last up jumped the cunning spider, and fiercely held her fast.
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
0.6.1
|
||||
0.7.0
|
||||
@@ -1 +0,0 @@
|
||||
testdata/dos-lines eol=crlf
|
||||
@@ -0,0 +1 @@
|
||||
/coverage.out
|
||||
+4
@@ -1,9 +1,13 @@
|
||||
Carlos A Becker <caarlos0@gmail.com>
|
||||
Claude Opus 4.6 <noreply@anthropic.com>
|
||||
Dustin Spicuzza <dustin@virtualroadside.com>
|
||||
Eugene Terentev <eugene@terentev.net>
|
||||
Kevin Burke <kevin@burke.dev>
|
||||
Mark Nevill <nev@improbable.io>
|
||||
Neil Williams <neil@reddit.com>
|
||||
Scott Lessans <slessans@gmail.com>
|
||||
Sergey Lukjanov <me@slukjanov.name>
|
||||
Simon Josefsson <simon@josefsson.org>
|
||||
Wayne Ashley Berry <wayneashleyberry@gmail.com>
|
||||
santosh653 <70637961+santosh653@users.noreply.github.com>
|
||||
sio2boss <sio2boss@users.noreply.github.com>
|
||||
+47
-1
@@ -1,7 +1,51 @@
|
||||
# Changes
|
||||
|
||||
## Version 1.2
|
||||
## Version 1.6 (released February 16, 2026)
|
||||
|
||||
- Support `~` as the user's home directory in `Include` directives, matching
|
||||
the behavior described in ssh_config(5). Thanks to Neil Williams for the report
|
||||
(#31).
|
||||
|
||||
- Strip surrounding double quotes from parsed values. OpenSSH allows values
|
||||
like `IdentityFile "/path/to/file"`, but Get/GetAll previously returned the
|
||||
quotes as literal characters. Quotes are now stripped from the returned value
|
||||
while preserving the original text for faithful roundtripping via String() and
|
||||
MarshalText(). Thanks to Furkan Türkal for the report (#61).
|
||||
|
||||
- Default to a space before `#` in end-of-line comments. When a Host or KV is
|
||||
created programmatically with an EOLComment, the output previously had no space
|
||||
before the `#` (e.g. `Host foo#comment`). A single space is now inserted by
|
||||
default. Thanks to Yonghui Cheng for the report (#50).
|
||||
|
||||
## Version 1.5 (released February 14, 2026)
|
||||
|
||||
- Implement Match support. Most of the Match spec is implemented, including
|
||||
`Match host`, `Match originalhost`, `Match user`, `Match localuser`, and `Match
|
||||
all`. `Match exec` is not yet implemented.
|
||||
|
||||
- Add SECURITY.md
|
||||
|
||||
- Add Dependabot configuration
|
||||
|
||||
## Version 1.4 (released August 19, 2025)
|
||||
|
||||
- Remove .gitattributes file (which was used to test different line endings, and
|
||||
caused issues in some build environments). Store tests/dos-lines as CRLF in git
|
||||
directly instead.
|
||||
|
||||
## Version 1.3 (released February 20, 2025)
|
||||
|
||||
- Add go.mod file (although this project has no dependencies).
|
||||
|
||||
- config: add UserSettings.ConfigFinder
|
||||
|
||||
- Various updates to CI and build environment
|
||||
|
||||
## Version 1.2 (released March 31, 2022)
|
||||
|
||||
- config: add DecodeBytes to directly read a byte array.
|
||||
|
||||
- Strip trailing whitespace from Host declarations and key/value pairs.
|
||||
Previously, if a Host declaration or a value had trailing whitespace, that
|
||||
whitespace would have been included as part of the value. This led to unexpected
|
||||
consequences. For example:
|
||||
@@ -17,3 +61,5 @@ unintuitive.
|
||||
|
||||
Instead, we strip the trailing whitespace in the configuration, which leads to
|
||||
more intuitive behavior.
|
||||
|
||||
- Add fuzz tests.
|
||||
+9
-8
@@ -1,21 +1,22 @@
|
||||
BUMP_VERSION := $(GOPATH)/bin/bump_version
|
||||
STATICCHECK := $(GOPATH)/bin/staticcheck
|
||||
WRITE_MAILMAP := $(GOPATH)/bin/write_mailmap
|
||||
|
||||
$(STATICCHECK):
|
||||
go get honnef.co/go/tools/cmd/staticcheck
|
||||
|
||||
lint: $(STATICCHECK)
|
||||
lint:
|
||||
go vet ./...
|
||||
$(STATICCHECK)
|
||||
go run honnef.co/go/tools/cmd/staticcheck@latest ./...
|
||||
go run github.com/kevinburke/differ@latest gofmt -s -w .
|
||||
|
||||
test: lint
|
||||
test:
|
||||
@# the timeout helps guard against infinite recursion
|
||||
go test -timeout=250ms ./...
|
||||
|
||||
race-test: lint
|
||||
race-test:
|
||||
go test -timeout=500ms -race ./...
|
||||
|
||||
coverage:
|
||||
go test -trimpath -timeout=250ms -coverprofile=coverage.out -covermode=atomic ./...
|
||||
go tool cover -func=coverage.out
|
||||
|
||||
$(BUMP_VERSION):
|
||||
go get -u github.com/kevinburke/bump_version
|
||||
|
||||
|
||||
+5
-5
@@ -82,11 +82,11 @@ file format.
|
||||
[blog]: https://kev.inburke.com/kevin/more-comment-preserving-configuration-parsers/
|
||||
[hostsfile]: https://github.com/kevinburke/hostsfile
|
||||
|
||||
## Donating
|
||||
## Sponsorships
|
||||
|
||||
I don't get paid to maintain this project. Donations free up time to make
|
||||
improvements to the library, and respond to bug reports. You can send donations
|
||||
via Paypal's "Send Money" feature to kev@inburke.com. Donations are not tax
|
||||
deductible in the USA.
|
||||
Thank you very much to Tailscale and Indeed for sponsoring development of this
|
||||
library. [Sponsors][sponsors] will get their names featured in the README.
|
||||
|
||||
You can also reach out about a consulting engagement: https://burke.services
|
||||
|
||||
[sponsors]: https://github.com/sponsors/kevinburke
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
# ssh_config security policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
As of September 2025, we're not aware of any security problems with ssh_config,
|
||||
past or present. That said, we recommend always using the latest version of
|
||||
ssh_config, and of the Go programming language, to ensure you have the most
|
||||
recent security fixes.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
We take security vulnerabilities seriously. If you discover a security vulnerability in ssh_config, please report it responsibly by following these steps:
|
||||
|
||||
### How to Report
|
||||
|
||||
Please follow the instructions outlined here to report a vulnerability
|
||||
privately: https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability
|
||||
|
||||
If these are insufficient - it is not hard to find Kevin's contact information
|
||||
on the Internet.
|
||||
|
||||
### What to Include
|
||||
|
||||
When reporting a vulnerability, please include a clear description of the vulnerability, steps to reproduce the issue, the potential impact, as well as any fixes you might have.
|
||||
|
||||
### Response Timeline
|
||||
|
||||
I'll try to acknowledge and patch the issue as quickly as possible.
|
||||
|
||||
Security advisories for this project will be published through:
|
||||
- GitHub Security Advisories on this repository
|
||||
- an Issue on this repository
|
||||
- The project's release notes
|
||||
- Go vulnerability databases
|
||||
|
||||
If you are using `ssh_config` and would like to be on a "pre-release"
|
||||
distribution list for coordinating releases, please contact Kevin directly.
|
||||
|
||||
### Security Considerations
|
||||
|
||||
When using ssh_config, please be aware of these security considerations.
|
||||
|
||||
#### File System Access
|
||||
|
||||
This library reads SSH configuration files from the file system. Try to ensure
|
||||
proper file permissions on SSH config files (typically 600 or 644), and be
|
||||
cautious when parsing config files from untrusted sources.
|
||||
|
||||
#### Input Validation
|
||||
|
||||
The parser handles user-provided SSH configuration data. While we try our best
|
||||
to parse the data appropriately, malformed configuration files could potentially
|
||||
cause issues. Please try to validate and sanitize any configuration data from
|
||||
external sources.
|
||||
|
||||
#### Dependencies
|
||||
|
||||
This project does not have any third party dependencies. Please try to keep your
|
||||
Go version up to date.
|
||||
|
||||
## Acknowledgments
|
||||
|
||||
We appreciate security researchers and users who responsibly disclose vulnerabilities. Contributors who report valid security issues will be acknowledged in our security advisories (unless they prefer to remain anonymous).
|
||||
+101
-26
@@ -8,7 +8,7 @@
|
||||
// the host name to match on ("example.com"), and the second argument is the key
|
||||
// you want to retrieve ("Port"). The keywords are case insensitive.
|
||||
//
|
||||
// port := ssh_config.Get("myhost", "Port")
|
||||
// port := ssh_config.Get("myhost", "Port")
|
||||
//
|
||||
// You can also manipulate an SSH config file and then print it or write it back
|
||||
// to disk.
|
||||
@@ -24,9 +24,6 @@
|
||||
//
|
||||
// // Write the cfg back to disk:
|
||||
// fmt.Println(cfg.String())
|
||||
//
|
||||
// BUG: the Match directive is currently unsupported; parsing a config with
|
||||
// a Match directive will trigger an error.
|
||||
package ssh_config
|
||||
|
||||
import (
|
||||
@@ -43,7 +40,7 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
const version = "1.2"
|
||||
const version = "1.6.0"
|
||||
|
||||
var _ = version
|
||||
|
||||
@@ -53,6 +50,8 @@ type configFinder func() string
|
||||
// files are parsed and cached the first time Get() or GetStrict() is called.
|
||||
type UserSettings struct {
|
||||
IgnoreErrors bool
|
||||
customConfig *Config
|
||||
customConfigFinder configFinder
|
||||
systemConfig *Config
|
||||
systemConfigFinder configFinder
|
||||
userConfig *Config
|
||||
@@ -203,6 +202,13 @@ func (u *UserSettings) GetStrict(alias, key string) (string, error) {
|
||||
if u.onceErr != nil && u.IgnoreErrors == false {
|
||||
return "", u.onceErr
|
||||
}
|
||||
// TODO this is getting repetitive
|
||||
if u.customConfig != nil {
|
||||
val, err := findVal(u.customConfig, alias, key)
|
||||
if err != nil || val != "" {
|
||||
return val, err
|
||||
}
|
||||
}
|
||||
val, err := findVal(u.userConfig, alias, key)
|
||||
if err != nil || val != "" {
|
||||
return val, err
|
||||
@@ -228,6 +234,12 @@ func (u *UserSettings) GetAllStrict(alias, key string) ([]string, error) {
|
||||
if u.onceErr != nil && u.IgnoreErrors == false {
|
||||
return nil, u.onceErr
|
||||
}
|
||||
if u.customConfig != nil {
|
||||
val, err := findAll(u.customConfig, alias, key)
|
||||
if err != nil || val != nil {
|
||||
return val, err
|
||||
}
|
||||
}
|
||||
val, err := findAll(u.userConfig, alias, key)
|
||||
if err != nil || val != nil {
|
||||
return val, err
|
||||
@@ -243,16 +255,38 @@ func (u *UserSettings) GetAllStrict(alias, key string) ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
// ConfigFinder will invoke f to try to find a ssh config file in a custom
|
||||
// location on disk, instead of in /etc/ssh or $HOME/.ssh. f should return the
|
||||
// name of a file containing SSH configuration.
|
||||
//
|
||||
// ConfigFinder must be invoked before any calls to Get or GetStrict and panics
|
||||
// if f is nil. Most users should not need to use this function.
|
||||
func (u *UserSettings) ConfigFinder(f func() string) {
|
||||
if f == nil {
|
||||
panic("cannot call ConfigFinder with nil function")
|
||||
}
|
||||
u.customConfigFinder = f
|
||||
}
|
||||
|
||||
func (u *UserSettings) doLoadConfigs() {
|
||||
u.loadConfigs.Do(func() {
|
||||
// can't parse user file, that's ok.
|
||||
var filename string
|
||||
var err error
|
||||
if u.customConfigFinder != nil {
|
||||
filename = u.customConfigFinder()
|
||||
u.customConfig, err = parseFile(filename)
|
||||
// IsNotExist should be returned because a user specified this
|
||||
// function - not existing likely means they made an error
|
||||
if err != nil {
|
||||
u.onceErr = err
|
||||
}
|
||||
return
|
||||
}
|
||||
if u.userConfigFinder == nil {
|
||||
filename = userConfigFinder()
|
||||
} else {
|
||||
filename = u.userConfigFinder()
|
||||
}
|
||||
var err error
|
||||
u.userConfig, err = parseFile(filename)
|
||||
//lint:ignore S1002 I prefer it this way
|
||||
if err != nil && os.IsNotExist(err) == false {
|
||||
@@ -351,9 +385,6 @@ func (c *Config) Get(alias, key string) (string, error) {
|
||||
case *KV:
|
||||
// "keys are case insensitive" per the spec
|
||||
lkey := strings.ToLower(t.Key)
|
||||
if lkey == "match" {
|
||||
panic("can't handle Match directives")
|
||||
}
|
||||
if lkey == lowerKey {
|
||||
return t.Value, nil
|
||||
}
|
||||
@@ -386,9 +417,6 @@ func (c *Config) GetAll(alias, key string) ([]string, error) {
|
||||
case *KV:
|
||||
// "keys are case insensitive" per the spec
|
||||
lkey := strings.ToLower(t.Key)
|
||||
if lkey == "match" {
|
||||
panic("can't handle Match directives")
|
||||
}
|
||||
if lkey == lowerKey {
|
||||
all = append(all, t.Value)
|
||||
}
|
||||
@@ -433,6 +461,9 @@ type Pattern struct {
|
||||
|
||||
// String prints the string representation of the pattern.
|
||||
func (p Pattern) String() string {
|
||||
if p.not {
|
||||
return "!" + p.str
|
||||
}
|
||||
return p.str
|
||||
}
|
||||
|
||||
@@ -491,7 +522,7 @@ func NewPattern(s string) (*Pattern, error) {
|
||||
return &Pattern{str: s, regex: r, not: negated}, nil
|
||||
}
|
||||
|
||||
// Host describes a Host directive and the keywords that follow it.
|
||||
// Host describes a Host or Match directive and the keywords that follow it.
|
||||
type Host struct {
|
||||
// A list of host patterns that should match this host.
|
||||
Patterns []*Pattern
|
||||
@@ -506,6 +537,11 @@ type Host struct {
|
||||
leadingSpace int // TODO: handle spaces vs tabs here.
|
||||
// The file starts with an implicit "Host *" declaration.
|
||||
implicit bool
|
||||
// isMatch is true if this block was created by a Match directive.
|
||||
isMatch bool
|
||||
// matchKeyword stores the original text after "Match" (e.g. "Host" or
|
||||
// "all") so we can round-trip correctly.
|
||||
matchKeyword string
|
||||
}
|
||||
|
||||
// Matches returns true if the Host matches for the given alias. For
|
||||
@@ -537,20 +573,43 @@ func (h *Host) String() string {
|
||||
//lint:ignore S1002 I prefer to write it this way
|
||||
if h.implicit == false {
|
||||
buf.WriteString(strings.Repeat(" ", int(h.leadingSpace)))
|
||||
buf.WriteString("Host")
|
||||
if h.hasEquals {
|
||||
buf.WriteString(" = ")
|
||||
} else {
|
||||
buf.WriteString(" ")
|
||||
}
|
||||
for i, pat := range h.Patterns {
|
||||
buf.WriteString(pat.String())
|
||||
if i < len(h.Patterns)-1 {
|
||||
if h.isMatch {
|
||||
buf.WriteString("Match")
|
||||
if h.hasEquals {
|
||||
buf.WriteString(" = ")
|
||||
} else {
|
||||
buf.WriteString(" ")
|
||||
}
|
||||
buf.WriteString(h.matchKeyword)
|
||||
if !strings.EqualFold(h.matchKeyword, "all") {
|
||||
buf.WriteString(" ")
|
||||
for i, pat := range h.Patterns {
|
||||
buf.WriteString(pat.String())
|
||||
if i < len(h.Patterns)-1 {
|
||||
buf.WriteString(" ")
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
buf.WriteString("Host")
|
||||
if h.hasEquals {
|
||||
buf.WriteString(" = ")
|
||||
} else {
|
||||
buf.WriteString(" ")
|
||||
}
|
||||
for i, pat := range h.Patterns {
|
||||
buf.WriteString(pat.String())
|
||||
if i < len(h.Patterns)-1 {
|
||||
buf.WriteString(" ")
|
||||
}
|
||||
}
|
||||
}
|
||||
buf.WriteString(h.spaceBeforeComment)
|
||||
if h.EOLComment != "" {
|
||||
if h.spaceBeforeComment != "" {
|
||||
buf.WriteString(h.spaceBeforeComment)
|
||||
} else {
|
||||
buf.WriteByte(' ')
|
||||
}
|
||||
buf.WriteByte('#')
|
||||
buf.WriteString(h.EOLComment)
|
||||
}
|
||||
@@ -580,6 +639,9 @@ type KV struct {
|
||||
hasEquals bool
|
||||
leadingSpace int // Space before the key. TODO handle spaces vs tabs.
|
||||
position Position
|
||||
// rawValue preserves the original value text (including surrounding double
|
||||
// quotes, if any) so that String() can roundtrip the config file faithfully.
|
||||
rawValue string
|
||||
}
|
||||
|
||||
// Pos returns k's Position.
|
||||
@@ -596,9 +658,20 @@ func (k *KV) String() string {
|
||||
if k.hasEquals {
|
||||
equals = " = "
|
||||
}
|
||||
line := strings.Repeat(" ", int(k.leadingSpace)) + k.Key + equals + k.Value + k.spaceAfterValue
|
||||
val := k.Value
|
||||
if k.rawValue != "" {
|
||||
val = k.rawValue
|
||||
}
|
||||
line := strings.Repeat(" ", int(k.leadingSpace)) + k.Key + equals + val
|
||||
if k.Comment != "" {
|
||||
if k.spaceAfterValue != "" {
|
||||
line += k.spaceAfterValue
|
||||
} else {
|
||||
line += " "
|
||||
}
|
||||
line += "#" + k.Comment
|
||||
} else {
|
||||
line += k.spaceAfterValue
|
||||
}
|
||||
return line
|
||||
}
|
||||
@@ -695,6 +768,8 @@ func NewInclude(directives []string, hasEquals bool, pos Position, comment strin
|
||||
path = directives[i]
|
||||
} else if system {
|
||||
path = filepath.Join("/etc/ssh", directives[i])
|
||||
} else if strings.HasPrefix(directives[i], "~/") {
|
||||
path = filepath.Join(homedir(), directives[i][2:])
|
||||
} else {
|
||||
path = filepath.Join(homedir(), ".ssh", directives[i])
|
||||
}
|
||||
@@ -792,7 +867,7 @@ func init() {
|
||||
func newConfig() *Config {
|
||||
return &Config{
|
||||
Hosts: []*Host{
|
||||
&Host{
|
||||
{
|
||||
implicit: true,
|
||||
Patterns: []*Pattern{matchAll},
|
||||
Nodes: make([]Node, 0),
|
||||
|
||||
+78
-8
@@ -21,9 +21,9 @@ type sshParser struct {
|
||||
type sshParserStateFn func() sshParserStateFn
|
||||
|
||||
// Formats and panics an error message based on a token
|
||||
func (p *sshParser) raiseErrorf(tok *token, msg string, args ...interface{}) {
|
||||
func (p *sshParser) raiseErrorf(tok *token, msg string) {
|
||||
// TODO this format is ugly
|
||||
panic(tok.Position.String() + ": " + fmt.Sprintf(msg, args...))
|
||||
panic(tok.Position.String() + ": " + msg)
|
||||
}
|
||||
|
||||
func (p *sshParser) raiseError(tok *token, err error) {
|
||||
@@ -105,9 +105,7 @@ func (p *sshParser) parseKV() sshParserStateFn {
|
||||
comment = tok.val
|
||||
}
|
||||
if strings.ToLower(key.val) == "match" {
|
||||
// https://github.com/kevinburke/ssh_config/issues/6
|
||||
p.raiseErrorf(val, "ssh_config: Match directive parsing is unsupported")
|
||||
return nil
|
||||
return p.parseMatch(val, hasEquals, comment)
|
||||
}
|
||||
if strings.ToLower(key.val) == "host" {
|
||||
strPatterns := strings.Split(val.val, " ")
|
||||
@@ -118,7 +116,7 @@ func (p *sshParser) parseKV() sshParserStateFn {
|
||||
}
|
||||
pat, err := NewPattern(strPatterns[i])
|
||||
if err != nil {
|
||||
p.raiseErrorf(val, "Invalid host pattern: %v", err)
|
||||
p.raiseErrorf(val, fmt.Sprintf("Invalid host pattern: %v", err))
|
||||
return nil
|
||||
}
|
||||
patterns = append(patterns, pat)
|
||||
@@ -144,7 +142,7 @@ func (p *sshParser) parseKV() sshParserStateFn {
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
p.raiseErrorf(val, "Error parsing Include directive: %v", err)
|
||||
p.raiseErrorf(val, fmt.Sprintf("Error parsing Include directive: %v", err))
|
||||
return nil
|
||||
}
|
||||
lastHost.Nodes = append(lastHost.Nodes, inc)
|
||||
@@ -152,9 +150,14 @@ func (p *sshParser) parseKV() sshParserStateFn {
|
||||
}
|
||||
shortval := strings.TrimRightFunc(val.val, unicode.IsSpace)
|
||||
spaceAfterValue := val.val[len(shortval):]
|
||||
unquoted := shortval
|
||||
if len(shortval) >= 2 && shortval[0] == '"' && shortval[len(shortval)-1] == '"' {
|
||||
unquoted = shortval[1 : len(shortval)-1]
|
||||
}
|
||||
kv := &KV{
|
||||
Key: key.val,
|
||||
Value: shortval,
|
||||
Value: unquoted,
|
||||
rawValue: shortval,
|
||||
spaceAfterValue: spaceAfterValue,
|
||||
Comment: comment,
|
||||
hasEquals: hasEquals,
|
||||
@@ -165,6 +168,73 @@ func (p *sshParser) parseKV() sshParserStateFn {
|
||||
return p.parseStart
|
||||
}
|
||||
|
||||
func (p *sshParser) parseMatch(val *token, hasEquals bool, comment string) sshParserStateFn {
|
||||
// val.val contains everything after "Match ", e.g. "Host *.example.com"
|
||||
// or "all".
|
||||
trimmed := strings.TrimRightFunc(val.val, unicode.IsSpace)
|
||||
spaceBeforeComment := val.val[len(trimmed):]
|
||||
fields := strings.Fields(trimmed)
|
||||
if len(fields) == 0 {
|
||||
p.raiseErrorf(val, "ssh_config: Match directive requires at least one criterion")
|
||||
return nil
|
||||
}
|
||||
criterion := strings.ToLower(fields[0])
|
||||
|
||||
switch criterion {
|
||||
case "all":
|
||||
// "Match all" is equivalent to "Host *" — matches everything.
|
||||
p.config.Hosts = append(p.config.Hosts, &Host{
|
||||
Patterns: []*Pattern{matchAll},
|
||||
Nodes: make([]Node, 0),
|
||||
EOLComment: comment,
|
||||
spaceBeforeComment: spaceBeforeComment,
|
||||
hasEquals: hasEquals,
|
||||
isMatch: true,
|
||||
matchKeyword: fields[0], // preserve original case
|
||||
})
|
||||
return p.parseStart
|
||||
|
||||
case "host":
|
||||
patterns := make([]*Pattern, 0)
|
||||
for _, s := range fields[1:] {
|
||||
if s == "" {
|
||||
continue
|
||||
}
|
||||
pat, err := NewPattern(s)
|
||||
if err != nil {
|
||||
p.raiseErrorf(val, fmt.Sprintf("Invalid host pattern: %v", err))
|
||||
return nil
|
||||
}
|
||||
patterns = append(patterns, pat)
|
||||
}
|
||||
if len(patterns) == 0 {
|
||||
p.raiseErrorf(val, "ssh_config: Match Host requires at least one pattern")
|
||||
return nil
|
||||
}
|
||||
p.config.Hosts = append(p.config.Hosts, &Host{
|
||||
Patterns: patterns,
|
||||
Nodes: make([]Node, 0),
|
||||
EOLComment: comment,
|
||||
spaceBeforeComment: spaceBeforeComment,
|
||||
hasEquals: hasEquals,
|
||||
isMatch: true,
|
||||
matchKeyword: fields[0], // preserve original case
|
||||
})
|
||||
return p.parseStart
|
||||
|
||||
case "exec":
|
||||
// Match Exec runs arbitrary commands. Supporting it would allow
|
||||
// untrusted SSH config files to execute code on the parsing
|
||||
// machine. Reject it explicitly.
|
||||
p.raiseErrorf(val, "ssh_config: Match Exec is not supported")
|
||||
return nil
|
||||
|
||||
default:
|
||||
p.raiseErrorf(val, fmt.Sprintf("ssh_config: unsupported Match criterion %q", criterion))
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p *sshParser) parseComment() sshParserStateFn {
|
||||
comment := p.getToken()
|
||||
lastHost := p.config.Hosts[len(p.config.Hosts)-1]
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ archives:
|
||||
name_template: "cpuid-{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
|
||||
format_overrides:
|
||||
- goos: windows
|
||||
format: zip
|
||||
formats: [ 'zip' ]
|
||||
files:
|
||||
- LICENSE
|
||||
checksum:
|
||||
|
||||
+69
-1
@@ -2,7 +2,7 @@
|
||||
Package cpuid provides information about the CPU running the current program.
|
||||
|
||||
CPU features are detected on startup, and kept for fast access through the life of the application.
|
||||
Currently x86 / x64 (AMD64/i386) and ARM (ARM64) is supported, and no external C (cgo) code is used, which should make the library very easy to use.
|
||||
Currently x86 / x64 (AMD64/i386), ARM (ARM64), and RISC-V (RV64) are supported, and no external C (cgo) code is used, which should make the library very easy to use.
|
||||
|
||||
You can access the CPU information by accessing the shared CPU variable of the cpuid library.
|
||||
|
||||
@@ -506,6 +506,74 @@ Exit Code 1
|
||||
| SM3 | SM3 instructions |
|
||||
| SM4 | SM4 instructions |
|
||||
| SVE | Scalable Vector Extension |
|
||||
| SVE2 | Scalable Vector Extension 2 |
|
||||
| SB | Speculation barrier (SB instruction) |
|
||||
| SSBS | Speculative Store Bypass Safe (PSTATE.SSBS) |
|
||||
| BTI | Branch Target Identification |
|
||||
| FLAGM2 | Condition flag manipulation version 2 (AXFLAG, XAFLAG) |
|
||||
| FRINTTS | Floating-point to integer rounding (FRINT32Z, FRINT64Z, etc) |
|
||||
| DCPODP | Data cache clean to Point of Deep Persistence (DC CVADP) |
|
||||
| BF16 | BFloat16 instructions (BFDOT, BFMMLA, etc) |
|
||||
| I8MM | Int8 matrix multiplication (SMMLA, UMMLA, USMMLA) |
|
||||
| WFXT | WFE/WFI with timeout (WFET, WFIT) |
|
||||
| MOPS | Memory copy and set instructions (CPYF, SETP, etc) |
|
||||
| HBC | Hinted conditional branches (BC.cond) |
|
||||
| CSSC | Common short sequence compression (ABS, SMAX, UMAX, etc) |
|
||||
|
||||
## riscv64 feature detection
|
||||
|
||||
On `riscv64/linux`, CPU features are detected using the `riscv_hwprobe` syscall (Linux 6.4+).
|
||||
For older kernels, detection falls back to parsing `/proc/cpuinfo` for the ISA string.
|
||||
|
||||
Cache line size is detected via `riscv_hwprobe` (Zicbom block size) or sysfs fallback.
|
||||
Other cache and topology information is not yet available.
|
||||
|
||||
# RISC-V features:
|
||||
|
||||
| Feature Flag | Description |
|
||||
|----------------|----------------------------------------------------|
|
||||
| RV_IMA | IMA base (Integer, Multiply, Atomic) |
|
||||
| RV_C | Compressed instructions |
|
||||
| RV_F | Single-precision FP |
|
||||
| RV_D | Double-precision FP |
|
||||
| RV_V | Vector extension (V) |
|
||||
| RV_ZBA | Address generation |
|
||||
| RV_ZBB | Basic bit manipulation |
|
||||
| RV_ZBC | Carry-less multiplication |
|
||||
| RV_ZBS | Single-bit manipulation |
|
||||
| RV_ZICOND | Integer conditional operations |
|
||||
| RV_ZIHINTPAUSE | Pause hint |
|
||||
| RV_ZICBOM | Cache block management operations |
|
||||
| RV_ZICBOZ | Cache block zero |
|
||||
| RV_ZICBOP | Cache block prefetch |
|
||||
| RV_ZFA | Additional floating-point |
|
||||
| RV_ZFH | Half-precision FP |
|
||||
| RV_ZFHMIN | Minimal half-precision FP |
|
||||
| RV_ZTSO | Total store ordering |
|
||||
| RV_ZACAS | Atomic CAS |
|
||||
| RV_ZBKB | Bit-manipulation for crypto |
|
||||
| RV_ZBKC | Carry-less multiply for crypto |
|
||||
| RV_ZBKX | Crossbar permutations |
|
||||
| RV_ZKND | NIST Suite: AES decrypt |
|
||||
| RV_ZKNE | NIST Suite: AES encrypt |
|
||||
| RV_ZKNH | NIST Suite: SHA-2 (SHA-256/SHA-512) |
|
||||
| RV_ZKSED | ShangMi Suite: SM4 block cipher |
|
||||
| RV_ZKSH | ShangMi Suite: SM3 hash |
|
||||
| RV_ZKT | Data-independent execution latency (Crypto) |
|
||||
| RV_ZKN | NIST Algorithm Suite (combined from individual) |
|
||||
| RV_ZKS | ShangMi Algorithm Suite (combined from individual) |
|
||||
| RV_ZVBB | Vector Basic Bit-manipulation |
|
||||
| RV_ZVBC | Vector Carry-less multiply |
|
||||
| RV_ZVKB | Vector Bit-manipulation for crypto |
|
||||
| RV_ZVKG | Vector GCM/GMAC |
|
||||
| RV_ZVKNED | NIST Suite: Vector AES encrypt+decrypt |
|
||||
| RV_ZVKNHA | NIST Suite: Vector SHA-2 (SHA-256) |
|
||||
| RV_ZVKNHB | NIST Suite: Vector SHA-2 (SHA-512) |
|
||||
| RV_ZVKSED | ShangMi Suite: Vector SM4 |
|
||||
| RV_ZVKSH | ShangMi Suite: Vector SM3 hash |
|
||||
| RV_ZVKT | Vector Data-independent execution latency |
|
||||
| RV_ZVKNG | NIST Suite with GCM (combined from individual) |
|
||||
| RV_ZVKSG | ShangMi Suite with GCM (combined from individual) |
|
||||
|
||||
# license
|
||||
|
||||
|
||||
+200
-13
@@ -3,7 +3,7 @@
|
||||
// Package cpuid provides information about the CPU running the current program.
|
||||
//
|
||||
// CPU features are detected on startup, and kept for fast access through the life of the application.
|
||||
// Currently x86 / x64 (AMD64) as well as arm64 is supported.
|
||||
// Currently x86 / x64 (AMD64), arm64, and riscv64 are supported.
|
||||
//
|
||||
// You can access the CPU information by accessing the shared CPU variable of the cpuid library.
|
||||
//
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"math/bits"
|
||||
"os"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -61,6 +62,13 @@ const (
|
||||
SRE
|
||||
Apple
|
||||
|
||||
// RISC-V vendors
|
||||
SiFive
|
||||
StarFive
|
||||
THead
|
||||
Andes
|
||||
SpacemiT
|
||||
|
||||
lastVendor
|
||||
)
|
||||
|
||||
@@ -95,6 +103,7 @@ const (
|
||||
AVX2 // AVX2 functions
|
||||
AVX512BF16 // AVX-512 BFLOAT16 Instructions
|
||||
AVX512BITALG // AVX-512 Bit Algorithms
|
||||
AVX512BMM // AVX-512 Bit Manipulation Instructions
|
||||
AVX512BW // AVX-512 Byte and Word Instructions
|
||||
AVX512CD // AVX-512 Conflict Detection Instructions
|
||||
AVX512DQ // AVX-512 Doubleword and Quadword Instructions
|
||||
@@ -139,6 +148,7 @@ const (
|
||||
FMA4 // Bulldozer FMA4 functions
|
||||
FP128 // AMD: When set, the internal FP/SIMD execution datapath is no more than 128-bits wide
|
||||
FP256 // AMD: When set, the internal FP/SIMD execution datapath is no more than 256-bits wide
|
||||
FRED // Flexible Return and Event Delivery
|
||||
FSRM // Fast Short Rep Mov
|
||||
FXSR // FXSAVE, FXRESTOR instructions, CR4 bit 9
|
||||
FXSROPT // FXSAVE/FXRSTOR optimizations
|
||||
@@ -308,6 +318,19 @@ const (
|
||||
SM3 // SM3 instructions
|
||||
SM4 // SM4 instructions
|
||||
SVE // Scalable Vector Extension
|
||||
SVE2 // Scalable Vector Extension 2
|
||||
SB // Speculation barrier (SB instruction)
|
||||
SSBS // Speculative Store Bypass Safe (PSTATE.SSBS)
|
||||
BTI // Branch Target Identification
|
||||
FLAGM2 // Condition flag manipulation version 2 (AXFLAG, XAFLAG)
|
||||
FRINTTS // Floating-point to integer rounding (FRINT32Z, FRINT64Z, etc)
|
||||
DCPODP // Data cache clean to Point of Deep Persistence (DC CVADP)
|
||||
BF16 // BFloat16 instructions (BFDOT, BFMMLA, etc)
|
||||
I8MM // Int8 matrix multiplication (SMMLA, UMMLA, USMMLA)
|
||||
WFXT // WFE/WFI with timeout (WFET, WFIT)
|
||||
MOPS // Memory copy and set instructions (CPYF, SETP, etc)
|
||||
HBC // Hinted conditional branches (BC.cond)
|
||||
CSSC // Common short sequence compression (ABS, SMAX, UMAX, etc)
|
||||
|
||||
// PMU
|
||||
PMU_FIXEDCOUNTER_CYCLES
|
||||
@@ -315,6 +338,57 @@ const (
|
||||
PMU_FIXEDCOUNTER_INSTRUCTIONS
|
||||
PMU_FIXEDCOUNTER_TOPDOWN_SLOTS
|
||||
|
||||
// RISC-V features
|
||||
RV_IMA // IMA base (Integer, Multiply, Atomic)
|
||||
RV_C // Compressed instructions
|
||||
RV_F // Single-precision FP
|
||||
RV_D // Double-precision FP
|
||||
RV_V // Vector extension (V)
|
||||
RV_ZBA // Address generation
|
||||
RV_ZBB // Basic bit manipulation
|
||||
RV_ZBC // Carry-less multiplication
|
||||
RV_ZBS // Single-bit manipulation
|
||||
RV_ZICOND // Integer conditional operations
|
||||
RV_ZIHINTPAUSE // Pause hint
|
||||
RV_ZICBOM // Cache block management operations
|
||||
RV_ZICBOZ // Cache block zero
|
||||
RV_ZICBOP // Cache block prefetch
|
||||
RV_ZFA // Additional floating-point
|
||||
RV_ZFH // Half-precision FP
|
||||
RV_ZFHMIN // Minimal half-precision FP
|
||||
RV_ZTSO // Total store ordering
|
||||
RV_ZACAS // Atomic CAS
|
||||
// Scalar cryptography
|
||||
RV_ZBKB // Bit-manipulation for crypto
|
||||
RV_ZBKC // Carry-less multiply for crypto
|
||||
RV_ZBKX // Crossbar permutations
|
||||
RV_ZKND // NIST Suite: AES decrypt
|
||||
RV_ZKNE // NIST Suite: AES encrypt
|
||||
RV_ZKNH // NIST Suite: SHA-2 (SHA-256/SHA-512)
|
||||
RV_ZKSED // ShangMi Suite: SM4 block cipher
|
||||
RV_ZKSH // ShangMi Suite: SM3 hash
|
||||
RV_ZKT // Data-independent execution latency (Crypto)
|
||||
|
||||
// Scalar crypto suites (combined from individual extensions)
|
||||
RV_ZKN // NIST Algorithm Suite (Zknd+Zkne+Zknh+Zbkb+Zbkc+Zbkx+Zkt)
|
||||
RV_ZKS // ShangMi Algorithm Suite (Zksed+Zksh+Zbkb+Zbkc+Zbkx+Zkt)
|
||||
|
||||
// Vector cryptography
|
||||
RV_ZVBB // Vector Basic Bit-manipulation
|
||||
RV_ZVBC // Vector Carry-less multiply
|
||||
RV_ZVKB // Vector Bit-manipulation for crypto
|
||||
RV_ZVKG // Vector GCM/GMAC
|
||||
RV_ZVKNED // NIST Suite: Vector AES encrypt+decrypt
|
||||
RV_ZVKNHA // NIST Suite: Vector SHA-2 (SHA-256)
|
||||
RV_ZVKNHB // NIST Suite: Vector SHA-2 (SHA-512)
|
||||
RV_ZVKSED // ShangMi Suite: Vector SM4
|
||||
RV_ZVKSH // ShangMi Suite: Vector SM3 hash
|
||||
RV_ZVKT // Vector Data-independent execution latency
|
||||
|
||||
// Vector crypto suites (combined from individual extensions)
|
||||
RV_ZVKNG // NIST Suite with GCM (Zvkned+Zvknhb+Zvkg+Zvkb+Zvkt)
|
||||
RV_ZVKSG // ShangMi Suite with GCM (Zvksed+Zvksh+Zvkg+Zvkb+Zvkt)
|
||||
|
||||
// Keep it last. It automatically defines the size of []flagSet
|
||||
lastID
|
||||
|
||||
@@ -419,8 +493,8 @@ func Detect() {
|
||||
os.Exit(1)
|
||||
}
|
||||
if disableFlag != nil {
|
||||
s := strings.Split(*disableFlag, ",")
|
||||
for _, feat := range s {
|
||||
s := strings.SplitSeq(*disableFlag, ",")
|
||||
for feat := range s {
|
||||
feat := ParseFeature(strings.TrimSpace(feat))
|
||||
if feat != UNKNOWN {
|
||||
CPU.featureSet.unset(feat)
|
||||
@@ -471,12 +545,7 @@ func (c *CPUInfo) Has(id FeatureID) bool {
|
||||
|
||||
// AnyOf returns whether the CPU supports one or more of the requested features.
|
||||
func (c CPUInfo) AnyOf(ids ...FeatureID) bool {
|
||||
for _, id := range ids {
|
||||
if c.featureSet.inSet(id) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.ContainsFunc(ids, c.featureSet.inSet)
|
||||
}
|
||||
|
||||
// Features contains several features combined for a fast check using
|
||||
@@ -496,6 +565,11 @@ func (c *CPUInfo) HasAll(f Features) bool {
|
||||
return c.featureSet.hasSetP(f)
|
||||
}
|
||||
|
||||
// HasOneOf returns whether the CPU supports one or more of the requested features.
|
||||
func (c *CPUInfo) HasOneOf(f Features) bool {
|
||||
return c.featureSet.hasOneOf(f)
|
||||
}
|
||||
|
||||
// https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels
|
||||
var oneOfLevel = CombineFeatures(SYSEE, SYSCALL)
|
||||
var level1Features = CombineFeatures(CMOV, CMPXCHG8, X87, FXSR, MMX, SSE, SSE2)
|
||||
@@ -503,6 +577,56 @@ var level2Features = CombineFeatures(CMOV, CMPXCHG8, X87, FXSR, MMX, SSE, SSE2,
|
||||
var level3Features = CombineFeatures(CMOV, CMPXCHG8, X87, FXSR, MMX, SSE, SSE2, CX16, LAHF, POPCNT, SSE3, SSE4, SSE42, SSSE3, AVX, AVX2, BMI1, BMI2, F16C, FMA3, LZCNT, MOVBE, OSXSAVE)
|
||||
var level4Features = CombineFeatures(CMOV, CMPXCHG8, X87, FXSR, MMX, SSE, SSE2, CX16, LAHF, POPCNT, SSE3, SSE4, SSE42, SSSE3, AVX, AVX2, BMI1, BMI2, F16C, FMA3, LZCNT, MOVBE, OSXSAVE, AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL)
|
||||
|
||||
// RV_CRYPTO_FEATS contains all RISC-V scalar cryptography instruction extensions (excludes Zkt since it is a timing guarantee, not a computational instruction).
|
||||
var RV_CRYPTO_FEATS = CombineFeatures(RV_ZBKB, RV_ZBKC, RV_ZBKX, RV_ZKND, RV_ZKNE, RV_ZKNH, RV_ZKSED, RV_ZKSH)
|
||||
|
||||
// RV_VECTOR_CRYPTO_FEATS contains all RISC-V vector cryptography extensions.
|
||||
var RV_VECTOR_CRYPTO_FEATS = CombineFeatures(RV_ZVBB, RV_ZVBC, RV_ZVKB, RV_ZVKG, RV_ZVKNED, RV_ZVKNHA, RV_ZVKNHB, RV_ZVKSED, RV_ZVKSH)
|
||||
|
||||
// RISC-V application profile feature sets.
|
||||
// https://github.com/riscv/riscv-profiles
|
||||
var rvProfile20Features = CombineFeatures(RV_IMA, RV_C, RV_F, RV_D)
|
||||
var rvProfile22Features = CombineFeatures(RV_IMA, RV_C, RV_F, RV_D, RV_ZBA, RV_ZBB, RV_ZBS, RV_ZFHMIN, RV_ZICBOM, RV_ZICBOP, RV_ZICBOZ, RV_ZIHINTPAUSE)
|
||||
var rvProfile23Features = CombineFeatures(RV_IMA, RV_C, RV_F, RV_D, RV_ZBA, RV_ZBB, RV_ZBS, RV_ZFHMIN, RV_ZICBOM, RV_ZICBOP, RV_ZICBOZ, RV_ZIHINTPAUSE, RV_V, RV_ZFA, RV_ZICOND, RV_ZVBB, RV_ZVKB)
|
||||
|
||||
// RISC-V crypto suites — combined from individual extensions.
|
||||
var rvZKNFeatures = CombineFeatures(RV_ZKND, RV_ZKNE, RV_ZKNH, RV_ZBKB, RV_ZBKC, RV_ZBKX, RV_ZKT)
|
||||
var rvZKSFeatures = CombineFeatures(RV_ZKSED, RV_ZKSH, RV_ZBKB, RV_ZBKC, RV_ZBKX, RV_ZKT)
|
||||
var rvZVKNFeatures = CombineFeatures(RV_ZVKNED, RV_ZVKNHB, RV_ZVKG, RV_ZVKB, RV_ZVKT)
|
||||
var rvZVKSFeatures = CombineFeatures(RV_ZVKSED, RV_ZVKSH, RV_ZVKG, RV_ZVKB, RV_ZVKT)
|
||||
|
||||
// ARM64 architecture levels. armV8Levels[m] is the cumulative set of mandatory
|
||||
// user-space instruction features added up to and including ARMv8.m that this
|
||||
// package can detect. EL1/system-only features (PAN, VHE, CSV2/CSV3, ECV, ...)
|
||||
// are excluded since they are irrelevant to user-space code generation, exactly
|
||||
// as X64Level ignores non-instruction features.
|
||||
//
|
||||
// FEAT_SSBS and FEAT_BTI, although mandatory from ARMv8.5, are intentionally NOT
|
||||
// required. Both are OS-policy-gated security features (speculative store bypass
|
||||
// safety and branch-target identification) that Go code generation never depends
|
||||
// on: their HWCAP/sysctl bits are set only when the OS or hypervisor enables the
|
||||
// protection, not purely from CPU capability, so they are routinely hidden even
|
||||
// on capable silicon (neither a Neoverse N2 Linux guest nor Apple Silicon reports
|
||||
// them). Requiring them would cap such CPUs at v8.4. Both are still detected and
|
||||
// reported through FeatureSet when present.
|
||||
// https://go.dev/wiki/MinimumRequirements#arm64
|
||||
var armV8Levels = [...]Features{
|
||||
CombineFeatures(FP, ASIMD), // v8.0
|
||||
CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM), // v8.1
|
||||
CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP), // v8.2
|
||||
CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC), // v8.3
|
||||
CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC, TS), // v8.4
|
||||
CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC, TS, SB, FRINTTS, FLAGM2, DCPODP), // v8.5
|
||||
CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC, TS, SB, FRINTTS, FLAGM2, DCPODP, BF16, I8MM), // v8.6
|
||||
CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC, TS, SB, FRINTTS, FLAGM2, DCPODP, BF16, I8MM, WFXT), // v8.7
|
||||
CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC, TS, SB, FRINTTS, FLAGM2, DCPODP, BF16, I8MM, WFXT, MOPS, HBC), // v8.8
|
||||
CombineFeatures(FP, ASIMD, ATOMICS, CRC32, ASIMDRDM, DCPOP, JSCVT, FCMA, LRCPC, TS, SB, FRINTTS, FLAGM2, DCPODP, BF16, I8MM, WFXT, MOPS, HBC, CSSC), // v8.9
|
||||
}
|
||||
|
||||
// armCrypto matches the GOARM64 ",crypto" option: FEAT_AES, FEAT_PMULL,
|
||||
// FEAT_SHA1 and FEAT_SHA256.
|
||||
var armCrypto = CombineFeatures(AESARM, PMULL, SHA1, SHA2)
|
||||
|
||||
// X64Level returns the microarchitecture level detected on the CPU.
|
||||
// If features are lacking or non x64 mode, 0 is returned.
|
||||
// See https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels
|
||||
@@ -525,6 +649,67 @@ func (c CPUInfo) X64Level() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// RVProfile returns the RISC-V application profile level.
|
||||
// 0 = unknown / base ISA only, 20 = RVA20, 22 = RVA22, 23 = RVA23.
|
||||
// Returns 0 on non-RISC-V architectures or if not detected.
|
||||
// https://github.com/riscv/riscv-profiles
|
||||
func (c CPUInfo) RVProfile() int {
|
||||
switch {
|
||||
case c.featureSet.hasSetP(rvProfile23Features):
|
||||
return 23
|
||||
case c.featureSet.hasSetP(rvProfile22Features):
|
||||
return 22
|
||||
case c.featureSet.hasSetP(rvProfile20Features):
|
||||
return 20
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
// ARM64Level returns the ARMv8/ARMv9 architecture version supported by the CPU
|
||||
// as (major, minor), e.g. 8, 4 for ARMv8.4-A or 9, 0 for ARMv9.0-A.
|
||||
// Only mandatory user-space instruction features are considered, so the result
|
||||
// is the highest level whose required instructions are all present.
|
||||
// Returns 0, 0 on non-arm64 CPUs or when feature detection was unavailable.
|
||||
func (c CPUInfo) ARM64Level() (major, minor int) {
|
||||
if !c.featureSet.hasSetP(armV8Levels[0]) {
|
||||
return 0, 0
|
||||
}
|
||||
m8 := 0
|
||||
for m := len(armV8Levels) - 1; m >= 1; m-- {
|
||||
if c.featureSet.hasSetP(armV8Levels[m]) {
|
||||
m8 = m
|
||||
break
|
||||
}
|
||||
}
|
||||
// ARMv9.x mandates everything in ARMv8.(x+5) plus SVE2.
|
||||
if m8 >= 5 && c.featureSet.inSet(SVE2) {
|
||||
return 9, m8 - 5
|
||||
}
|
||||
return 8, m8
|
||||
}
|
||||
|
||||
// GOARM64 returns a value usable as the GOARM64 build setting for the detected
|
||||
// CPU, e.g. "v8.4" or "v9.0,crypto". The ",crypto" suffix is appended when AES,
|
||||
// PMULL, SHA1 and SHA256 are all present; the ",lse" suffix is appended in the
|
||||
// rare case LSE is present without the rest of the ARMv8.1 feature set.
|
||||
// Returns "" on non-arm64 CPUs or when feature detection was unavailable.
|
||||
// See https://go.dev/wiki/MinimumRequirements#arm64
|
||||
func (c CPUInfo) GOARM64() string {
|
||||
major, minor := c.ARM64Level()
|
||||
if major == 0 {
|
||||
return ""
|
||||
}
|
||||
v := fmt.Sprintf("v%d.%d", major, minor)
|
||||
if major == 8 && minor == 0 && c.featureSet.inSet(ATOMICS) {
|
||||
v += ",lse"
|
||||
}
|
||||
if c.featureSet.hasSetP(armCrypto) {
|
||||
v += ",crypto"
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Disable will disable one or several features.
|
||||
func (c *CPUInfo) Disable(ids ...FeatureID) bool {
|
||||
for _, id := range ids {
|
||||
@@ -771,7 +956,7 @@ func flagSetWith(feat ...FeatureID) flagSet {
|
||||
// Will return UNKNOWN if not found.
|
||||
func ParseFeature(s string) FeatureID {
|
||||
s = strings.ToUpper(s)
|
||||
for i := firstID; i < lastID; i++ {
|
||||
for i := range lastID {
|
||||
if i.String() == s {
|
||||
return i
|
||||
}
|
||||
@@ -785,7 +970,7 @@ func (s flagSet) Strings() []string {
|
||||
return []string{""}
|
||||
}
|
||||
r := make([]string, 0)
|
||||
for i := firstID; i < lastID; i++ {
|
||||
for i := range lastID {
|
||||
if s.inSet(i) {
|
||||
r = append(r, i.String())
|
||||
}
|
||||
@@ -806,7 +991,7 @@ func maxFunctionID() uint32 {
|
||||
func brandName() string {
|
||||
if maxExtendedFunction() >= 0x80000004 {
|
||||
v := make([]uint32, 0, 48)
|
||||
for i := uint32(0); i < 3; i++ {
|
||||
for i := range uint32(3) {
|
||||
a, b, c, d := cpuid(0x80000002 + i)
|
||||
v = append(v, a, b, c, d)
|
||||
}
|
||||
@@ -1075,7 +1260,7 @@ func (c *CPUInfo) cacheSize() {
|
||||
// Hack: When we encounter the same entry 100 times we break.
|
||||
nSame := 0
|
||||
var last uint32
|
||||
for i := uint32(0); i < math.MaxUint32; i++ {
|
||||
for i := range uint32(math.MaxUint32) {
|
||||
eax, ebx, ecx, _ := cpuidex(0x8000001D, i)
|
||||
|
||||
level := (eax >> 5) & 7
|
||||
@@ -1329,6 +1514,7 @@ func support() flagSet {
|
||||
fs.setIf(eax1&(1<<10) != 0, MOVSB_ZL)
|
||||
fs.setIf(eax1&(1<<11) != 0, STOSB_SHORT)
|
||||
fs.setIf(eax1&(1<<12) != 0, CMPSB_SCADBS_SHORT)
|
||||
fs.setIf(eax1&(1<<17) != 0, FRED)
|
||||
fs.setIf(eax1&(1<<22) != 0, HRESET)
|
||||
fs.setIf(eax1&(1<<23) != 0, AVXIFMA)
|
||||
fs.setIf(eax1&(1<<26) != 0, LAM)
|
||||
@@ -1562,6 +1748,7 @@ func support() flagSet {
|
||||
fs.setIf((a>>29)&1 == 1, SRSO_NO)
|
||||
fs.setIf((a>>28)&1 == 1, IBPB_BRTYPE)
|
||||
fs.setIf((a>>27)&1 == 1, SBPB)
|
||||
fs.setIf((a>>23)&1 == 1, AVX512BMM)
|
||||
fs.setIf((c>>1)&1 == 1, TSA_L1_NO)
|
||||
fs.setIf((c>>2)&1 == 1, TSA_SQ_NO)
|
||||
fs.setIf((a>>5)&1 == 1, TSA_VERW_CLEAR)
|
||||
|
||||
+8
-1
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file.
|
||||
|
||||
//go:build arm64 && !gccgo && !noasm && !appengine
|
||||
// +build arm64,!gccgo,!noasm,!appengine
|
||||
|
||||
package cpuid
|
||||
|
||||
@@ -189,6 +188,7 @@ func addInfo(c *CPUInfo, safe bool) {
|
||||
f.setIf(instAttrReg0&(0xf<<60) != 0, RNDR)
|
||||
f.setIf(instAttrReg0&(0xf<<56) != 0, TLB)
|
||||
f.setIf(instAttrReg0&(0xf<<52) != 0, TS)
|
||||
f.setIf(instAttrReg0&(0xf<<52) == 2<<52, FLAGM2) // TS == 0b0010 (FEAT_FlagM2)
|
||||
f.setIf(instAttrReg0&(0xf<<48) != 0, FHM)
|
||||
f.setIf(instAttrReg0&(0xf<<44) != 0, ASIMDDP)
|
||||
f.setIf(instAttrReg0&(0xf<<40) != 0, SM4)
|
||||
@@ -244,6 +244,13 @@ func addInfo(c *CPUInfo, safe bool) {
|
||||
// fmt.Println("APA")
|
||||
// }
|
||||
f.setIf(instAttrReg1&(0xf<<0) != 0, DCPOP)
|
||||
f.setIf(instAttrReg1&(0xf<<0) == 2<<0, DCPODP) // DPB == 0b0010 (FEAT_DPB2)
|
||||
|
||||
// Upper ID_AA64ISAR1_EL1 fields, not in the table above.
|
||||
f.setIf(instAttrReg1&(0xf<<32) != 0, FRINTTS) // bits [35:32]
|
||||
f.setIf(instAttrReg1&(0xf<<36) != 0, SB) // bits [39:36]
|
||||
f.setIf(instAttrReg1&(0xf<<44) != 0, BF16) // bits [47:44]
|
||||
f.setIf(instAttrReg1&(0xf<<52) != 0, I8MM) // bits [55:52]
|
||||
|
||||
// Store
|
||||
c.featureSet.or(f)
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file.
|
||||
|
||||
//go:build (!amd64 && !386 && !arm64) || gccgo || noasm || appengine
|
||||
// +build !amd64,!386,!arm64 gccgo noasm appengine
|
||||
//go:build (!amd64 && !386 && !arm64 && !riscv64) || ((amd64 || 386) && (gccgo || noasm || appengine))
|
||||
|
||||
package cpuid
|
||||
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file.
|
||||
|
||||
//go:build arm64 && (gccgo || noasm || appengine)
|
||||
|
||||
package cpuid
|
||||
|
||||
func initCPU() {
|
||||
cpuid = func(uint32) (a, b, c, d uint32) { return 0, 0, 0, 0 }
|
||||
cpuidex = func(x, y uint32) (a, b, c, d uint32) { return 0, 0, 0, 0 }
|
||||
xgetbv = func(uint32) (a, b uint32) { return 0, 0 }
|
||||
rdtscpAsm = func() (a, b, c, d uint32) { return 0, 0, 0, 0 }
|
||||
}
|
||||
|
||||
func addInfo(c *CPUInfo, safe bool) {
|
||||
c.CacheLine = 64
|
||||
detectOS(c)
|
||||
}
|
||||
|
||||
func getVectorLength() (vl, pl uint64) { return 0, 0 }
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2026 Klaus Post, released under MIT License. See LICENSE file.
|
||||
|
||||
package cpuid
|
||||
|
||||
func getVectorLength() (vl, pl uint64) { return 0, 0 }
|
||||
|
||||
func initCPU() {
|
||||
cpuid = func(uint32) (a, b, c, d uint32) { return 0, 0, 0, 0 }
|
||||
cpuidex = func(x, y uint32) (a, b, c, d uint32) { return 0, 0, 0, 0 }
|
||||
xgetbv = func(uint32) (a, b uint32) { return 0, 0 }
|
||||
rdtscpAsm = func() (a, b, c, d uint32) { return 0, 0, 0, 0 }
|
||||
}
|
||||
|
||||
func addInfo(c *CPUInfo, safe bool) {
|
||||
detectOS(c)
|
||||
}
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2015 Klaus Post, released under MIT License. See LICENSE file.
|
||||
|
||||
//go:build (386 && !gccgo && !noasm && !appengine) || (amd64 && !gccgo && !noasm && !appengine)
|
||||
// +build 386,!gccgo,!noasm,!appengine amd64,!gccgo,!noasm,!appengine
|
||||
|
||||
package cpuid
|
||||
|
||||
|
||||
+289
-225
@@ -29,234 +29,292 @@ func _() {
|
||||
_ = x[AVX2-19]
|
||||
_ = x[AVX512BF16-20]
|
||||
_ = x[AVX512BITALG-21]
|
||||
_ = x[AVX512BW-22]
|
||||
_ = x[AVX512CD-23]
|
||||
_ = x[AVX512DQ-24]
|
||||
_ = x[AVX512ER-25]
|
||||
_ = x[AVX512F-26]
|
||||
_ = x[AVX512FP16-27]
|
||||
_ = x[AVX512IFMA-28]
|
||||
_ = x[AVX512PF-29]
|
||||
_ = x[AVX512VBMI-30]
|
||||
_ = x[AVX512VBMI2-31]
|
||||
_ = x[AVX512VL-32]
|
||||
_ = x[AVX512VNNI-33]
|
||||
_ = x[AVX512VP2INTERSECT-34]
|
||||
_ = x[AVX512VPOPCNTDQ-35]
|
||||
_ = x[AVXIFMA-36]
|
||||
_ = x[AVXNECONVERT-37]
|
||||
_ = x[AVXSLOW-38]
|
||||
_ = x[AVXVNNI-39]
|
||||
_ = x[AVXVNNIINT8-40]
|
||||
_ = x[AVXVNNIINT16-41]
|
||||
_ = x[BHI_CTRL-42]
|
||||
_ = x[BMI1-43]
|
||||
_ = x[BMI2-44]
|
||||
_ = x[CETIBT-45]
|
||||
_ = x[CETSS-46]
|
||||
_ = x[CLDEMOTE-47]
|
||||
_ = x[CLMUL-48]
|
||||
_ = x[CLZERO-49]
|
||||
_ = x[CMOV-50]
|
||||
_ = x[CMPCCXADD-51]
|
||||
_ = x[CMPSB_SCADBS_SHORT-52]
|
||||
_ = x[CMPXCHG8-53]
|
||||
_ = x[CPBOOST-54]
|
||||
_ = x[CPPC-55]
|
||||
_ = x[CX16-56]
|
||||
_ = x[EFER_LMSLE_UNS-57]
|
||||
_ = x[ENQCMD-58]
|
||||
_ = x[ERMS-59]
|
||||
_ = x[F16C-60]
|
||||
_ = x[FLUSH_L1D-61]
|
||||
_ = x[FMA3-62]
|
||||
_ = x[FMA4-63]
|
||||
_ = x[FP128-64]
|
||||
_ = x[FP256-65]
|
||||
_ = x[FSRM-66]
|
||||
_ = x[FXSR-67]
|
||||
_ = x[FXSROPT-68]
|
||||
_ = x[GFNI-69]
|
||||
_ = x[HLE-70]
|
||||
_ = x[HRESET-71]
|
||||
_ = x[HTT-72]
|
||||
_ = x[HWA-73]
|
||||
_ = x[HYBRID_CPU-74]
|
||||
_ = x[HYPERVISOR-75]
|
||||
_ = x[IA32_ARCH_CAP-76]
|
||||
_ = x[IA32_CORE_CAP-77]
|
||||
_ = x[IBPB-78]
|
||||
_ = x[IBPB_BRTYPE-79]
|
||||
_ = x[IBRS-80]
|
||||
_ = x[IBRS_PREFERRED-81]
|
||||
_ = x[IBRS_PROVIDES_SMP-82]
|
||||
_ = x[IBS-83]
|
||||
_ = x[IBSBRNTRGT-84]
|
||||
_ = x[IBSFETCHSAM-85]
|
||||
_ = x[IBSFFV-86]
|
||||
_ = x[IBSOPCNT-87]
|
||||
_ = x[IBSOPCNTEXT-88]
|
||||
_ = x[IBSOPSAM-89]
|
||||
_ = x[IBSRDWROPCNT-90]
|
||||
_ = x[IBSRIPINVALIDCHK-91]
|
||||
_ = x[IBS_FETCH_CTLX-92]
|
||||
_ = x[IBS_OPDATA4-93]
|
||||
_ = x[IBS_OPFUSE-94]
|
||||
_ = x[IBS_PREVENTHOST-95]
|
||||
_ = x[IBS_ZEN4-96]
|
||||
_ = x[IDPRED_CTRL-97]
|
||||
_ = x[INT_WBINVD-98]
|
||||
_ = x[INVLPGB-99]
|
||||
_ = x[KEYLOCKER-100]
|
||||
_ = x[KEYLOCKERW-101]
|
||||
_ = x[LAHF-102]
|
||||
_ = x[LAM-103]
|
||||
_ = x[LBRVIRT-104]
|
||||
_ = x[LZCNT-105]
|
||||
_ = x[MCAOVERFLOW-106]
|
||||
_ = x[MCDT_NO-107]
|
||||
_ = x[MCOMMIT-108]
|
||||
_ = x[MD_CLEAR-109]
|
||||
_ = x[MMX-110]
|
||||
_ = x[MMXEXT-111]
|
||||
_ = x[MOVBE-112]
|
||||
_ = x[MOVDIR64B-113]
|
||||
_ = x[MOVDIRI-114]
|
||||
_ = x[MOVSB_ZL-115]
|
||||
_ = x[MOVU-116]
|
||||
_ = x[MPX-117]
|
||||
_ = x[MSRIRC-118]
|
||||
_ = x[MSRLIST-119]
|
||||
_ = x[MSR_PAGEFLUSH-120]
|
||||
_ = x[NRIPS-121]
|
||||
_ = x[NX-122]
|
||||
_ = x[OSXSAVE-123]
|
||||
_ = x[PCONFIG-124]
|
||||
_ = x[POPCNT-125]
|
||||
_ = x[PPIN-126]
|
||||
_ = x[PREFETCHI-127]
|
||||
_ = x[PSFD-128]
|
||||
_ = x[RDPRU-129]
|
||||
_ = x[RDRAND-130]
|
||||
_ = x[RDSEED-131]
|
||||
_ = x[RDTSCP-132]
|
||||
_ = x[RRSBA_CTRL-133]
|
||||
_ = x[RTM-134]
|
||||
_ = x[RTM_ALWAYS_ABORT-135]
|
||||
_ = x[SBPB-136]
|
||||
_ = x[SERIALIZE-137]
|
||||
_ = x[SEV-138]
|
||||
_ = x[SEV_64BIT-139]
|
||||
_ = x[SEV_ALTERNATIVE-140]
|
||||
_ = x[SEV_DEBUGSWAP-141]
|
||||
_ = x[SEV_ES-142]
|
||||
_ = x[SEV_RESTRICTED-143]
|
||||
_ = x[SEV_SNP-144]
|
||||
_ = x[SGX-145]
|
||||
_ = x[SGXLC-146]
|
||||
_ = x[SGXPQC-147]
|
||||
_ = x[SHA-148]
|
||||
_ = x[SME-149]
|
||||
_ = x[SME_COHERENT-150]
|
||||
_ = x[SM3_X86-151]
|
||||
_ = x[SM4_X86-152]
|
||||
_ = x[SPEC_CTRL_SSBD-153]
|
||||
_ = x[SRBDS_CTRL-154]
|
||||
_ = x[SRSO_MSR_FIX-155]
|
||||
_ = x[SRSO_NO-156]
|
||||
_ = x[SRSO_USER_KERNEL_NO-157]
|
||||
_ = x[SSE-158]
|
||||
_ = x[SSE2-159]
|
||||
_ = x[SSE3-160]
|
||||
_ = x[SSE4-161]
|
||||
_ = x[SSE42-162]
|
||||
_ = x[SSE4A-163]
|
||||
_ = x[SSSE3-164]
|
||||
_ = x[STIBP-165]
|
||||
_ = x[STIBP_ALWAYSON-166]
|
||||
_ = x[STOSB_SHORT-167]
|
||||
_ = x[SUCCOR-168]
|
||||
_ = x[SVM-169]
|
||||
_ = x[SVMDA-170]
|
||||
_ = x[SVMFBASID-171]
|
||||
_ = x[SVML-172]
|
||||
_ = x[SVMNP-173]
|
||||
_ = x[SVMPF-174]
|
||||
_ = x[SVMPFT-175]
|
||||
_ = x[SYSCALL-176]
|
||||
_ = x[SYSEE-177]
|
||||
_ = x[TBM-178]
|
||||
_ = x[TDX_GUEST-179]
|
||||
_ = x[TLB_FLUSH_NESTED-180]
|
||||
_ = x[TME-181]
|
||||
_ = x[TOPEXT-182]
|
||||
_ = x[TSA_L1_NO-183]
|
||||
_ = x[TSA_SQ_NO-184]
|
||||
_ = x[TSA_VERW_CLEAR-185]
|
||||
_ = x[TSCRATEMSR-186]
|
||||
_ = x[TSXLDTRK-187]
|
||||
_ = x[VAES-188]
|
||||
_ = x[VMCBCLEAN-189]
|
||||
_ = x[VMPL-190]
|
||||
_ = x[VMSA_REGPROT-191]
|
||||
_ = x[VMX-192]
|
||||
_ = x[VPCLMULQDQ-193]
|
||||
_ = x[VTE-194]
|
||||
_ = x[WAITPKG-195]
|
||||
_ = x[WBNOINVD-196]
|
||||
_ = x[WRMSRNS-197]
|
||||
_ = x[X87-198]
|
||||
_ = x[XGETBV1-199]
|
||||
_ = x[XOP-200]
|
||||
_ = x[XSAVE-201]
|
||||
_ = x[XSAVEC-202]
|
||||
_ = x[XSAVEOPT-203]
|
||||
_ = x[XSAVES-204]
|
||||
_ = x[AESARM-205]
|
||||
_ = x[ARMCPUID-206]
|
||||
_ = x[ASIMD-207]
|
||||
_ = x[ASIMDDP-208]
|
||||
_ = x[ASIMDHP-209]
|
||||
_ = x[ASIMDRDM-210]
|
||||
_ = x[ATOMICS-211]
|
||||
_ = x[CRC32-212]
|
||||
_ = x[DCPOP-213]
|
||||
_ = x[EVTSTRM-214]
|
||||
_ = x[FCMA-215]
|
||||
_ = x[FHM-216]
|
||||
_ = x[FP-217]
|
||||
_ = x[FPHP-218]
|
||||
_ = x[GPA-219]
|
||||
_ = x[JSCVT-220]
|
||||
_ = x[LRCPC-221]
|
||||
_ = x[PMULL-222]
|
||||
_ = x[RNDR-223]
|
||||
_ = x[TLB-224]
|
||||
_ = x[TS-225]
|
||||
_ = x[SHA1-226]
|
||||
_ = x[SHA2-227]
|
||||
_ = x[SHA3-228]
|
||||
_ = x[SHA512-229]
|
||||
_ = x[SM3-230]
|
||||
_ = x[SM4-231]
|
||||
_ = x[SVE-232]
|
||||
_ = x[PMU_FIXEDCOUNTER_CYCLES-233]
|
||||
_ = x[PMU_FIXEDCOUNTER_REFCYCLES-234]
|
||||
_ = x[PMU_FIXEDCOUNTER_INSTRUCTIONS-235]
|
||||
_ = x[PMU_FIXEDCOUNTER_TOPDOWN_SLOTS-236]
|
||||
_ = x[lastID-237]
|
||||
_ = x[AVX512BMM-22]
|
||||
_ = x[AVX512BW-23]
|
||||
_ = x[AVX512CD-24]
|
||||
_ = x[AVX512DQ-25]
|
||||
_ = x[AVX512ER-26]
|
||||
_ = x[AVX512F-27]
|
||||
_ = x[AVX512FP16-28]
|
||||
_ = x[AVX512IFMA-29]
|
||||
_ = x[AVX512PF-30]
|
||||
_ = x[AVX512VBMI-31]
|
||||
_ = x[AVX512VBMI2-32]
|
||||
_ = x[AVX512VL-33]
|
||||
_ = x[AVX512VNNI-34]
|
||||
_ = x[AVX512VP2INTERSECT-35]
|
||||
_ = x[AVX512VPOPCNTDQ-36]
|
||||
_ = x[AVXIFMA-37]
|
||||
_ = x[AVXNECONVERT-38]
|
||||
_ = x[AVXSLOW-39]
|
||||
_ = x[AVXVNNI-40]
|
||||
_ = x[AVXVNNIINT8-41]
|
||||
_ = x[AVXVNNIINT16-42]
|
||||
_ = x[BHI_CTRL-43]
|
||||
_ = x[BMI1-44]
|
||||
_ = x[BMI2-45]
|
||||
_ = x[CETIBT-46]
|
||||
_ = x[CETSS-47]
|
||||
_ = x[CLDEMOTE-48]
|
||||
_ = x[CLMUL-49]
|
||||
_ = x[CLZERO-50]
|
||||
_ = x[CMOV-51]
|
||||
_ = x[CMPCCXADD-52]
|
||||
_ = x[CMPSB_SCADBS_SHORT-53]
|
||||
_ = x[CMPXCHG8-54]
|
||||
_ = x[CPBOOST-55]
|
||||
_ = x[CPPC-56]
|
||||
_ = x[CX16-57]
|
||||
_ = x[EFER_LMSLE_UNS-58]
|
||||
_ = x[ENQCMD-59]
|
||||
_ = x[ERMS-60]
|
||||
_ = x[F16C-61]
|
||||
_ = x[FLUSH_L1D-62]
|
||||
_ = x[FMA3-63]
|
||||
_ = x[FMA4-64]
|
||||
_ = x[FP128-65]
|
||||
_ = x[FP256-66]
|
||||
_ = x[FRED-67]
|
||||
_ = x[FSRM-68]
|
||||
_ = x[FXSR-69]
|
||||
_ = x[FXSROPT-70]
|
||||
_ = x[GFNI-71]
|
||||
_ = x[HLE-72]
|
||||
_ = x[HRESET-73]
|
||||
_ = x[HTT-74]
|
||||
_ = x[HWA-75]
|
||||
_ = x[HYBRID_CPU-76]
|
||||
_ = x[HYPERVISOR-77]
|
||||
_ = x[IA32_ARCH_CAP-78]
|
||||
_ = x[IA32_CORE_CAP-79]
|
||||
_ = x[IBPB-80]
|
||||
_ = x[IBPB_BRTYPE-81]
|
||||
_ = x[IBRS-82]
|
||||
_ = x[IBRS_PREFERRED-83]
|
||||
_ = x[IBRS_PROVIDES_SMP-84]
|
||||
_ = x[IBS-85]
|
||||
_ = x[IBSBRNTRGT-86]
|
||||
_ = x[IBSFETCHSAM-87]
|
||||
_ = x[IBSFFV-88]
|
||||
_ = x[IBSOPCNT-89]
|
||||
_ = x[IBSOPCNTEXT-90]
|
||||
_ = x[IBSOPSAM-91]
|
||||
_ = x[IBSRDWROPCNT-92]
|
||||
_ = x[IBSRIPINVALIDCHK-93]
|
||||
_ = x[IBS_FETCH_CTLX-94]
|
||||
_ = x[IBS_OPDATA4-95]
|
||||
_ = x[IBS_OPFUSE-96]
|
||||
_ = x[IBS_PREVENTHOST-97]
|
||||
_ = x[IBS_ZEN4-98]
|
||||
_ = x[IDPRED_CTRL-99]
|
||||
_ = x[INT_WBINVD-100]
|
||||
_ = x[INVLPGB-101]
|
||||
_ = x[KEYLOCKER-102]
|
||||
_ = x[KEYLOCKERW-103]
|
||||
_ = x[LAHF-104]
|
||||
_ = x[LAM-105]
|
||||
_ = x[LBRVIRT-106]
|
||||
_ = x[LZCNT-107]
|
||||
_ = x[MCAOVERFLOW-108]
|
||||
_ = x[MCDT_NO-109]
|
||||
_ = x[MCOMMIT-110]
|
||||
_ = x[MD_CLEAR-111]
|
||||
_ = x[MMX-112]
|
||||
_ = x[MMXEXT-113]
|
||||
_ = x[MOVBE-114]
|
||||
_ = x[MOVDIR64B-115]
|
||||
_ = x[MOVDIRI-116]
|
||||
_ = x[MOVSB_ZL-117]
|
||||
_ = x[MOVU-118]
|
||||
_ = x[MPX-119]
|
||||
_ = x[MSRIRC-120]
|
||||
_ = x[MSRLIST-121]
|
||||
_ = x[MSR_PAGEFLUSH-122]
|
||||
_ = x[NRIPS-123]
|
||||
_ = x[NX-124]
|
||||
_ = x[OSXSAVE-125]
|
||||
_ = x[PCONFIG-126]
|
||||
_ = x[POPCNT-127]
|
||||
_ = x[PPIN-128]
|
||||
_ = x[PREFETCHI-129]
|
||||
_ = x[PSFD-130]
|
||||
_ = x[RDPRU-131]
|
||||
_ = x[RDRAND-132]
|
||||
_ = x[RDSEED-133]
|
||||
_ = x[RDTSCP-134]
|
||||
_ = x[RRSBA_CTRL-135]
|
||||
_ = x[RTM-136]
|
||||
_ = x[RTM_ALWAYS_ABORT-137]
|
||||
_ = x[SBPB-138]
|
||||
_ = x[SERIALIZE-139]
|
||||
_ = x[SEV-140]
|
||||
_ = x[SEV_64BIT-141]
|
||||
_ = x[SEV_ALTERNATIVE-142]
|
||||
_ = x[SEV_DEBUGSWAP-143]
|
||||
_ = x[SEV_ES-144]
|
||||
_ = x[SEV_RESTRICTED-145]
|
||||
_ = x[SEV_SNP-146]
|
||||
_ = x[SGX-147]
|
||||
_ = x[SGXLC-148]
|
||||
_ = x[SGXPQC-149]
|
||||
_ = x[SHA-150]
|
||||
_ = x[SME-151]
|
||||
_ = x[SME_COHERENT-152]
|
||||
_ = x[SM3_X86-153]
|
||||
_ = x[SM4_X86-154]
|
||||
_ = x[SPEC_CTRL_SSBD-155]
|
||||
_ = x[SRBDS_CTRL-156]
|
||||
_ = x[SRSO_MSR_FIX-157]
|
||||
_ = x[SRSO_NO-158]
|
||||
_ = x[SRSO_USER_KERNEL_NO-159]
|
||||
_ = x[SSE-160]
|
||||
_ = x[SSE2-161]
|
||||
_ = x[SSE3-162]
|
||||
_ = x[SSE4-163]
|
||||
_ = x[SSE42-164]
|
||||
_ = x[SSE4A-165]
|
||||
_ = x[SSSE3-166]
|
||||
_ = x[STIBP-167]
|
||||
_ = x[STIBP_ALWAYSON-168]
|
||||
_ = x[STOSB_SHORT-169]
|
||||
_ = x[SUCCOR-170]
|
||||
_ = x[SVM-171]
|
||||
_ = x[SVMDA-172]
|
||||
_ = x[SVMFBASID-173]
|
||||
_ = x[SVML-174]
|
||||
_ = x[SVMNP-175]
|
||||
_ = x[SVMPF-176]
|
||||
_ = x[SVMPFT-177]
|
||||
_ = x[SYSCALL-178]
|
||||
_ = x[SYSEE-179]
|
||||
_ = x[TBM-180]
|
||||
_ = x[TDX_GUEST-181]
|
||||
_ = x[TLB_FLUSH_NESTED-182]
|
||||
_ = x[TME-183]
|
||||
_ = x[TOPEXT-184]
|
||||
_ = x[TSA_L1_NO-185]
|
||||
_ = x[TSA_SQ_NO-186]
|
||||
_ = x[TSA_VERW_CLEAR-187]
|
||||
_ = x[TSCRATEMSR-188]
|
||||
_ = x[TSXLDTRK-189]
|
||||
_ = x[VAES-190]
|
||||
_ = x[VMCBCLEAN-191]
|
||||
_ = x[VMPL-192]
|
||||
_ = x[VMSA_REGPROT-193]
|
||||
_ = x[VMX-194]
|
||||
_ = x[VPCLMULQDQ-195]
|
||||
_ = x[VTE-196]
|
||||
_ = x[WAITPKG-197]
|
||||
_ = x[WBNOINVD-198]
|
||||
_ = x[WRMSRNS-199]
|
||||
_ = x[X87-200]
|
||||
_ = x[XGETBV1-201]
|
||||
_ = x[XOP-202]
|
||||
_ = x[XSAVE-203]
|
||||
_ = x[XSAVEC-204]
|
||||
_ = x[XSAVEOPT-205]
|
||||
_ = x[XSAVES-206]
|
||||
_ = x[AESARM-207]
|
||||
_ = x[ARMCPUID-208]
|
||||
_ = x[ASIMD-209]
|
||||
_ = x[ASIMDDP-210]
|
||||
_ = x[ASIMDHP-211]
|
||||
_ = x[ASIMDRDM-212]
|
||||
_ = x[ATOMICS-213]
|
||||
_ = x[CRC32-214]
|
||||
_ = x[DCPOP-215]
|
||||
_ = x[EVTSTRM-216]
|
||||
_ = x[FCMA-217]
|
||||
_ = x[FHM-218]
|
||||
_ = x[FP-219]
|
||||
_ = x[FPHP-220]
|
||||
_ = x[GPA-221]
|
||||
_ = x[JSCVT-222]
|
||||
_ = x[LRCPC-223]
|
||||
_ = x[PMULL-224]
|
||||
_ = x[RNDR-225]
|
||||
_ = x[TLB-226]
|
||||
_ = x[TS-227]
|
||||
_ = x[SHA1-228]
|
||||
_ = x[SHA2-229]
|
||||
_ = x[SHA3-230]
|
||||
_ = x[SHA512-231]
|
||||
_ = x[SM3-232]
|
||||
_ = x[SM4-233]
|
||||
_ = x[SVE-234]
|
||||
_ = x[SVE2-235]
|
||||
_ = x[SB-236]
|
||||
_ = x[SSBS-237]
|
||||
_ = x[BTI-238]
|
||||
_ = x[FLAGM2-239]
|
||||
_ = x[FRINTTS-240]
|
||||
_ = x[DCPODP-241]
|
||||
_ = x[BF16-242]
|
||||
_ = x[I8MM-243]
|
||||
_ = x[WFXT-244]
|
||||
_ = x[MOPS-245]
|
||||
_ = x[HBC-246]
|
||||
_ = x[CSSC-247]
|
||||
_ = x[PMU_FIXEDCOUNTER_CYCLES-248]
|
||||
_ = x[PMU_FIXEDCOUNTER_REFCYCLES-249]
|
||||
_ = x[PMU_FIXEDCOUNTER_INSTRUCTIONS-250]
|
||||
_ = x[PMU_FIXEDCOUNTER_TOPDOWN_SLOTS-251]
|
||||
_ = x[RV_IMA-252]
|
||||
_ = x[RV_C-253]
|
||||
_ = x[RV_F-254]
|
||||
_ = x[RV_D-255]
|
||||
_ = x[RV_V-256]
|
||||
_ = x[RV_ZBA-257]
|
||||
_ = x[RV_ZBB-258]
|
||||
_ = x[RV_ZBC-259]
|
||||
_ = x[RV_ZBS-260]
|
||||
_ = x[RV_ZICOND-261]
|
||||
_ = x[RV_ZIHINTPAUSE-262]
|
||||
_ = x[RV_ZICBOM-263]
|
||||
_ = x[RV_ZICBOZ-264]
|
||||
_ = x[RV_ZICBOP-265]
|
||||
_ = x[RV_ZFA-266]
|
||||
_ = x[RV_ZFH-267]
|
||||
_ = x[RV_ZFHMIN-268]
|
||||
_ = x[RV_ZTSO-269]
|
||||
_ = x[RV_ZACAS-270]
|
||||
_ = x[RV_ZBKB-271]
|
||||
_ = x[RV_ZBKC-272]
|
||||
_ = x[RV_ZBKX-273]
|
||||
_ = x[RV_ZKND-274]
|
||||
_ = x[RV_ZKNE-275]
|
||||
_ = x[RV_ZKNH-276]
|
||||
_ = x[RV_ZKSED-277]
|
||||
_ = x[RV_ZKSH-278]
|
||||
_ = x[RV_ZKT-279]
|
||||
_ = x[RV_ZKN-280]
|
||||
_ = x[RV_ZKS-281]
|
||||
_ = x[RV_ZVBB-282]
|
||||
_ = x[RV_ZVBC-283]
|
||||
_ = x[RV_ZVKB-284]
|
||||
_ = x[RV_ZVKG-285]
|
||||
_ = x[RV_ZVKNED-286]
|
||||
_ = x[RV_ZVKNHA-287]
|
||||
_ = x[RV_ZVKNHB-288]
|
||||
_ = x[RV_ZVKSED-289]
|
||||
_ = x[RV_ZVKSH-290]
|
||||
_ = x[RV_ZVKT-291]
|
||||
_ = x[RV_ZVKNG-292]
|
||||
_ = x[RV_ZVKSG-293]
|
||||
_ = x[lastID-294]
|
||||
_ = x[firstID-0]
|
||||
}
|
||||
|
||||
const _FeatureID_name = "firstIDADXAESNIAMD3DNOWAMD3DNOWEXTAMXBF16AMXFP16AMXINT8AMXFP8AMXTILEAMXTF32AMXCOMPLEXAMXTRANSPOSEAPX_FAVXAVX10AVX10_128AVX10_256AVX10_512AVX2AVX512BF16AVX512BITALGAVX512BWAVX512CDAVX512DQAVX512ERAVX512FAVX512FP16AVX512IFMAAVX512PFAVX512VBMIAVX512VBMI2AVX512VLAVX512VNNIAVX512VP2INTERSECTAVX512VPOPCNTDQAVXIFMAAVXNECONVERTAVXSLOWAVXVNNIAVXVNNIINT8AVXVNNIINT16BHI_CTRLBMI1BMI2CETIBTCETSSCLDEMOTECLMULCLZEROCMOVCMPCCXADDCMPSB_SCADBS_SHORTCMPXCHG8CPBOOSTCPPCCX16EFER_LMSLE_UNSENQCMDERMSF16CFLUSH_L1DFMA3FMA4FP128FP256FSRMFXSRFXSROPTGFNIHLEHRESETHTTHWAHYBRID_CPUHYPERVISORIA32_ARCH_CAPIA32_CORE_CAPIBPBIBPB_BRTYPEIBRSIBRS_PREFERREDIBRS_PROVIDES_SMPIBSIBSBRNTRGTIBSFETCHSAMIBSFFVIBSOPCNTIBSOPCNTEXTIBSOPSAMIBSRDWROPCNTIBSRIPINVALIDCHKIBS_FETCH_CTLXIBS_OPDATA4IBS_OPFUSEIBS_PREVENTHOSTIBS_ZEN4IDPRED_CTRLINT_WBINVDINVLPGBKEYLOCKERKEYLOCKERWLAHFLAMLBRVIRTLZCNTMCAOVERFLOWMCDT_NOMCOMMITMD_CLEARMMXMMXEXTMOVBEMOVDIR64BMOVDIRIMOVSB_ZLMOVUMPXMSRIRCMSRLISTMSR_PAGEFLUSHNRIPSNXOSXSAVEPCONFIGPOPCNTPPINPREFETCHIPSFDRDPRURDRANDRDSEEDRDTSCPRRSBA_CTRLRTMRTM_ALWAYS_ABORTSBPBSERIALIZESEVSEV_64BITSEV_ALTERNATIVESEV_DEBUGSWAPSEV_ESSEV_RESTRICTEDSEV_SNPSGXSGXLCSGXPQCSHASMESME_COHERENTSM3_X86SM4_X86SPEC_CTRL_SSBDSRBDS_CTRLSRSO_MSR_FIXSRSO_NOSRSO_USER_KERNEL_NOSSESSE2SSE3SSE4SSE42SSE4ASSSE3STIBPSTIBP_ALWAYSONSTOSB_SHORTSUCCORSVMSVMDASVMFBASIDSVMLSVMNPSVMPFSVMPFTSYSCALLSYSEETBMTDX_GUESTTLB_FLUSH_NESTEDTMETOPEXTTSA_L1_NOTSA_SQ_NOTSA_VERW_CLEARTSCRATEMSRTSXLDTRKVAESVMCBCLEANVMPLVMSA_REGPROTVMXVPCLMULQDQVTEWAITPKGWBNOINVDWRMSRNSX87XGETBV1XOPXSAVEXSAVECXSAVEOPTXSAVESAESARMARMCPUIDASIMDASIMDDPASIMDHPASIMDRDMATOMICSCRC32DCPOPEVTSTRMFCMAFHMFPFPHPGPAJSCVTLRCPCPMULLRNDRTLBTSSHA1SHA2SHA3SHA512SM3SM4SVEPMU_FIXEDCOUNTER_CYCLESPMU_FIXEDCOUNTER_REFCYCLESPMU_FIXEDCOUNTER_INSTRUCTIONSPMU_FIXEDCOUNTER_TOPDOWN_SLOTSlastID"
|
||||
const _FeatureID_name = "firstIDADXAESNIAMD3DNOWAMD3DNOWEXTAMXBF16AMXFP16AMXINT8AMXFP8AMXTILEAMXTF32AMXCOMPLEXAMXTRANSPOSEAPX_FAVXAVX10AVX10_128AVX10_256AVX10_512AVX2AVX512BF16AVX512BITALGAVX512BMMAVX512BWAVX512CDAVX512DQAVX512ERAVX512FAVX512FP16AVX512IFMAAVX512PFAVX512VBMIAVX512VBMI2AVX512VLAVX512VNNIAVX512VP2INTERSECTAVX512VPOPCNTDQAVXIFMAAVXNECONVERTAVXSLOWAVXVNNIAVXVNNIINT8AVXVNNIINT16BHI_CTRLBMI1BMI2CETIBTCETSSCLDEMOTECLMULCLZEROCMOVCMPCCXADDCMPSB_SCADBS_SHORTCMPXCHG8CPBOOSTCPPCCX16EFER_LMSLE_UNSENQCMDERMSF16CFLUSH_L1DFMA3FMA4FP128FP256FREDFSRMFXSRFXSROPTGFNIHLEHRESETHTTHWAHYBRID_CPUHYPERVISORIA32_ARCH_CAPIA32_CORE_CAPIBPBIBPB_BRTYPEIBRSIBRS_PREFERREDIBRS_PROVIDES_SMPIBSIBSBRNTRGTIBSFETCHSAMIBSFFVIBSOPCNTIBSOPCNTEXTIBSOPSAMIBSRDWROPCNTIBSRIPINVALIDCHKIBS_FETCH_CTLXIBS_OPDATA4IBS_OPFUSEIBS_PREVENTHOSTIBS_ZEN4IDPRED_CTRLINT_WBINVDINVLPGBKEYLOCKERKEYLOCKERWLAHFLAMLBRVIRTLZCNTMCAOVERFLOWMCDT_NOMCOMMITMD_CLEARMMXMMXEXTMOVBEMOVDIR64BMOVDIRIMOVSB_ZLMOVUMPXMSRIRCMSRLISTMSR_PAGEFLUSHNRIPSNXOSXSAVEPCONFIGPOPCNTPPINPREFETCHIPSFDRDPRURDRANDRDSEEDRDTSCPRRSBA_CTRLRTMRTM_ALWAYS_ABORTSBPBSERIALIZESEVSEV_64BITSEV_ALTERNATIVESEV_DEBUGSWAPSEV_ESSEV_RESTRICTEDSEV_SNPSGXSGXLCSGXPQCSHASMESME_COHERENTSM3_X86SM4_X86SPEC_CTRL_SSBDSRBDS_CTRLSRSO_MSR_FIXSRSO_NOSRSO_USER_KERNEL_NOSSESSE2SSE3SSE4SSE42SSE4ASSSE3STIBPSTIBP_ALWAYSONSTOSB_SHORTSUCCORSVMSVMDASVMFBASIDSVMLSVMNPSVMPFSVMPFTSYSCALLSYSEETBMTDX_GUESTTLB_FLUSH_NESTEDTMETOPEXTTSA_L1_NOTSA_SQ_NOTSA_VERW_CLEARTSCRATEMSRTSXLDTRKVAESVMCBCLEANVMPLVMSA_REGPROTVMXVPCLMULQDQVTEWAITPKGWBNOINVDWRMSRNSX87XGETBV1XOPXSAVEXSAVECXSAVEOPTXSAVESAESARMARMCPUIDASIMDASIMDDPASIMDHPASIMDRDMATOMICSCRC32DCPOPEVTSTRMFCMAFHMFPFPHPGPAJSCVTLRCPCPMULLRNDRTLBTSSHA1SHA2SHA3SHA512SM3SM4SVESVE2SBSSBSBTIFLAGM2FRINTTSDCPODPBF16I8MMWFXTMOPSHBCCSSCPMU_FIXEDCOUNTER_CYCLESPMU_FIXEDCOUNTER_REFCYCLESPMU_FIXEDCOUNTER_INSTRUCTIONSPMU_FIXEDCOUNTER_TOPDOWN_SLOTSRV_IMARV_CRV_FRV_DRV_VRV_ZBARV_ZBBRV_ZBCRV_ZBSRV_ZICONDRV_ZIHINTPAUSERV_ZICBOMRV_ZICBOZRV_ZICBOPRV_ZFARV_ZFHRV_ZFHMINRV_ZTSORV_ZACASRV_ZBKBRV_ZBKCRV_ZBKXRV_ZKNDRV_ZKNERV_ZKNHRV_ZKSEDRV_ZKSHRV_ZKTRV_ZKNRV_ZKSRV_ZVBBRV_ZVBCRV_ZVKBRV_ZVKGRV_ZVKNEDRV_ZVKNHARV_ZVKNHBRV_ZVKSEDRV_ZVKSHRV_ZVKTRV_ZVKNGRV_ZVKSGlastID"
|
||||
|
||||
var _FeatureID_index = [...]uint16{0, 7, 10, 15, 23, 34, 41, 48, 55, 61, 68, 75, 85, 97, 102, 105, 110, 119, 128, 137, 141, 151, 163, 171, 179, 187, 195, 202, 212, 222, 230, 240, 251, 259, 269, 287, 302, 309, 321, 328, 335, 346, 358, 366, 370, 374, 380, 385, 393, 398, 404, 408, 417, 435, 443, 450, 454, 458, 472, 478, 482, 486, 495, 499, 503, 508, 513, 517, 521, 528, 532, 535, 541, 544, 547, 557, 567, 580, 593, 597, 608, 612, 626, 643, 646, 656, 667, 673, 681, 692, 700, 712, 728, 742, 753, 763, 778, 786, 797, 807, 814, 823, 833, 837, 840, 847, 852, 863, 870, 877, 885, 888, 894, 899, 908, 915, 923, 927, 930, 936, 943, 956, 961, 963, 970, 977, 983, 987, 996, 1000, 1005, 1011, 1017, 1023, 1033, 1036, 1052, 1056, 1065, 1068, 1077, 1092, 1105, 1111, 1125, 1132, 1135, 1140, 1146, 1149, 1152, 1164, 1171, 1178, 1192, 1202, 1214, 1221, 1240, 1243, 1247, 1251, 1255, 1260, 1265, 1270, 1275, 1289, 1300, 1306, 1309, 1314, 1323, 1327, 1332, 1337, 1343, 1350, 1355, 1358, 1367, 1383, 1386, 1392, 1401, 1410, 1424, 1434, 1442, 1446, 1455, 1459, 1471, 1474, 1484, 1487, 1494, 1502, 1509, 1512, 1519, 1522, 1527, 1533, 1541, 1547, 1553, 1561, 1566, 1573, 1580, 1588, 1595, 1600, 1605, 1612, 1616, 1619, 1621, 1625, 1628, 1633, 1638, 1643, 1647, 1650, 1652, 1656, 1660, 1664, 1670, 1673, 1676, 1679, 1702, 1728, 1757, 1787, 1793}
|
||||
var _FeatureID_index = [...]uint16{0, 7, 10, 15, 23, 34, 41, 48, 55, 61, 68, 75, 85, 97, 102, 105, 110, 119, 128, 137, 141, 151, 163, 172, 180, 188, 196, 204, 211, 221, 231, 239, 249, 260, 268, 278, 296, 311, 318, 330, 337, 344, 355, 367, 375, 379, 383, 389, 394, 402, 407, 413, 417, 426, 444, 452, 459, 463, 467, 481, 487, 491, 495, 504, 508, 512, 517, 522, 526, 530, 534, 541, 545, 548, 554, 557, 560, 570, 580, 593, 606, 610, 621, 625, 639, 656, 659, 669, 680, 686, 694, 705, 713, 725, 741, 755, 766, 776, 791, 799, 810, 820, 827, 836, 846, 850, 853, 860, 865, 876, 883, 890, 898, 901, 907, 912, 921, 928, 936, 940, 943, 949, 956, 969, 974, 976, 983, 990, 996, 1000, 1009, 1013, 1018, 1024, 1030, 1036, 1046, 1049, 1065, 1069, 1078, 1081, 1090, 1105, 1118, 1124, 1138, 1145, 1148, 1153, 1159, 1162, 1165, 1177, 1184, 1191, 1205, 1215, 1227, 1234, 1253, 1256, 1260, 1264, 1268, 1273, 1278, 1283, 1288, 1302, 1313, 1319, 1322, 1327, 1336, 1340, 1345, 1350, 1356, 1363, 1368, 1371, 1380, 1396, 1399, 1405, 1414, 1423, 1437, 1447, 1455, 1459, 1468, 1472, 1484, 1487, 1497, 1500, 1507, 1515, 1522, 1525, 1532, 1535, 1540, 1546, 1554, 1560, 1566, 1574, 1579, 1586, 1593, 1601, 1608, 1613, 1618, 1625, 1629, 1632, 1634, 1638, 1641, 1646, 1651, 1656, 1660, 1663, 1665, 1669, 1673, 1677, 1683, 1686, 1689, 1692, 1696, 1698, 1702, 1705, 1711, 1718, 1724, 1728, 1732, 1736, 1740, 1743, 1747, 1770, 1796, 1825, 1855, 1861, 1865, 1869, 1873, 1877, 1883, 1889, 1895, 1901, 1910, 1924, 1933, 1942, 1951, 1957, 1963, 1972, 1979, 1987, 1994, 2001, 2008, 2015, 2022, 2029, 2037, 2044, 2050, 2056, 2062, 2069, 2076, 2083, 2090, 2099, 2108, 2117, 2126, 2134, 2141, 2149, 2157, 2163}
|
||||
|
||||
func (i FeatureID) String() string {
|
||||
if i < 0 || i >= FeatureID(len(_FeatureID_index)-1) {
|
||||
idx := int(i) - 0
|
||||
if i < 0 || idx >= len(_FeatureID_index)-1 {
|
||||
return "FeatureID(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _FeatureID_name[_FeatureID_index[i]:_FeatureID_index[i+1]]
|
||||
return _FeatureID_name[_FeatureID_index[idx]:_FeatureID_index[idx+1]]
|
||||
}
|
||||
func _() {
|
||||
// An "invalid array index" compiler error signifies that the constant values have changed.
|
||||
@@ -293,16 +351,22 @@ func _() {
|
||||
_ = x[ACRN-28]
|
||||
_ = x[SRE-29]
|
||||
_ = x[Apple-30]
|
||||
_ = x[lastVendor-31]
|
||||
_ = x[SiFive-31]
|
||||
_ = x[StarFive-32]
|
||||
_ = x[THead-33]
|
||||
_ = x[Andes-34]
|
||||
_ = x[SpacemiT-35]
|
||||
_ = x[lastVendor-36]
|
||||
}
|
||||
|
||||
const _Vendor_name = "VendorUnknownIntelAMDVIATransmetaNSCKVMMSVMVMwareXenHVMBhyveHygonSiSRDCAmpereARMBroadcomCaviumDECFujitsuInfineonMotorolaNVIDIAAMCCQualcommMarvellQEMUQNXACRNSREApplelastVendor"
|
||||
const _Vendor_name = "VendorUnknownIntelAMDVIATransmetaNSCKVMMSVMVMwareXenHVMBhyveHygonSiSRDCAmpereARMBroadcomCaviumDECFujitsuInfineonMotorolaNVIDIAAMCCQualcommMarvellQEMUQNXACRNSREAppleSiFiveStarFiveTHeadAndesSpacemiTlastVendor"
|
||||
|
||||
var _Vendor_index = [...]uint8{0, 13, 18, 21, 24, 33, 36, 39, 43, 49, 55, 60, 65, 68, 71, 77, 80, 88, 94, 97, 104, 112, 120, 126, 130, 138, 145, 149, 152, 156, 159, 164, 174}
|
||||
var _Vendor_index = [...]uint8{0, 13, 18, 21, 24, 33, 36, 39, 43, 49, 55, 60, 65, 68, 71, 77, 80, 88, 94, 97, 104, 112, 120, 126, 130, 138, 145, 149, 152, 156, 159, 164, 170, 178, 183, 188, 196, 206}
|
||||
|
||||
func (i Vendor) String() string {
|
||||
if i < 0 || i >= Vendor(len(_Vendor_index)-1) {
|
||||
idx := int(i) - 0
|
||||
if i < 0 || idx >= len(_Vendor_index)-1 {
|
||||
return "Vendor(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||
}
|
||||
return _Vendor_name[_Vendor_index[i]:_Vendor_index[i+1]]
|
||||
return _Vendor_name[_Vendor_index[idx]:_Vendor_index[idx+1]]
|
||||
}
|
||||
+13
@@ -126,4 +126,17 @@ func tryToFillCPUInfoFomSysctl(c *CPUInfo) {
|
||||
setFeature(c, SM3, "hw.optional.arm.FEAT_SM3") // SM3 instructions
|
||||
setFeature(c, SM4, "hw.optional.arm.FEAT_SM4") // SM4 instructions
|
||||
setFeature(c, SVE, "hw.optional.arm.FEAT_SVE") // Scalable Vector Extension
|
||||
setFeature(c, SVE2, "hw.optional.arm.FEAT_SVE2") // Scalable Vector Extension 2
|
||||
setFeature(c, SB, "hw.optional.arm.FEAT_SB") // Speculation barrier
|
||||
setFeature(c, SSBS, "hw.optional.arm.FEAT_SSBS") // Speculative Store Bypass Safe
|
||||
setFeature(c, BTI, "hw.optional.arm.FEAT_BTI") // Branch Target Identification
|
||||
setFeature(c, FLAGM2, "hw.optional.arm.FEAT_FlagM2") // Condition flag manipulation version 2
|
||||
setFeature(c, FRINTTS, "hw.optional.arm.FEAT_FRINTTS") // Floating-point to integer rounding
|
||||
setFeature(c, DCPODP, "hw.optional.arm.FEAT_DPB2") // Data cache clean to Point of Deep Persistence
|
||||
setFeature(c, BF16, "hw.optional.arm.FEAT_BF16") // BFloat16 instructions
|
||||
setFeature(c, I8MM, "hw.optional.arm.FEAT_I8MM") // Int8 matrix multiplication
|
||||
setFeature(c, WFXT, "hw.optional.arm.FEAT_WFxT") // WFE/WFI with timeout
|
||||
setFeature(c, MOPS, "hw.optional.arm.FEAT_MOPS") // Memory copy and set instructions
|
||||
setFeature(c, HBC, "hw.optional.arm.FEAT_HBC") // Hinted conditional branches
|
||||
setFeature(c, CSSC, "hw.optional.arm.FEAT_CSSC") // Common short sequence compression
|
||||
}
|
||||
+52
-36
@@ -115,15 +115,19 @@ const (
|
||||
hwcap2_POE = 1 << 63
|
||||
)
|
||||
|
||||
// hwcap2 holds AT_HWCAP2. Unlike hwcap, the arm64 runtime does not expose it
|
||||
// through internal/cpu, so detectOS reads it from the auxiliary vector.
|
||||
var hwcap2 uint
|
||||
|
||||
func detectOS(c *CPUInfo) bool {
|
||||
// For now assuming no hyperthreading is reasonable.
|
||||
c.LogicalCores = runtime.NumCPU()
|
||||
c.PhysicalCores = c.LogicalCores
|
||||
c.ThreadsPerCore = 1
|
||||
if hwcap == 0 {
|
||||
// We did not get values from the runtime.
|
||||
// Try reading /proc/self/auxv
|
||||
|
||||
// hwcap is provided by the runtime through the internal/cpu.HWCap linkname,
|
||||
// but the runtime does not expose HWCAP2 on arm64. Read the auxiliary vector
|
||||
// directly to obtain hwcap2 (and hwcap when the linkname is unavailable).
|
||||
if hwcap == 0 || hwcap2 == 0 {
|
||||
// From https://github.com/golang/sys
|
||||
const (
|
||||
_AT_HWCAP = 16
|
||||
@@ -132,37 +136,34 @@ func detectOS(c *CPUInfo) bool {
|
||||
uintSize = int(32 << (^uint(0) >> 63))
|
||||
)
|
||||
|
||||
buf, err := ioutil.ReadFile("/proc/self/auxv")
|
||||
if err != nil {
|
||||
// e.g. on android /proc/self/auxv is not accessible, so silently
|
||||
// ignore the error and leave Initialized = false. On some
|
||||
// architectures (e.g. arm64) doinit() implements a fallback
|
||||
// readout and will set Initialized = true again.
|
||||
return false
|
||||
}
|
||||
bo := binary.LittleEndian
|
||||
for len(buf) >= 2*(uintSize/8) {
|
||||
var tag, val uint
|
||||
switch uintSize {
|
||||
case 32:
|
||||
tag = uint(bo.Uint32(buf[0:]))
|
||||
val = uint(bo.Uint32(buf[4:]))
|
||||
buf = buf[8:]
|
||||
case 64:
|
||||
tag = uint(bo.Uint64(buf[0:]))
|
||||
val = uint(bo.Uint64(buf[8:]))
|
||||
buf = buf[16:]
|
||||
}
|
||||
switch tag {
|
||||
case _AT_HWCAP:
|
||||
hwcap = val
|
||||
case _AT_HWCAP2:
|
||||
// Not used
|
||||
// e.g. on android /proc/self/auxv is not accessible, so silently ignore
|
||||
// the error and fall back to whatever the runtime provided.
|
||||
if buf, err := ioutil.ReadFile("/proc/self/auxv"); err == nil {
|
||||
bo := binary.LittleEndian
|
||||
for len(buf) >= 2*(uintSize/8) {
|
||||
var tag, val uint
|
||||
switch uintSize {
|
||||
case 32:
|
||||
tag = uint(bo.Uint32(buf[0:]))
|
||||
val = uint(bo.Uint32(buf[4:]))
|
||||
buf = buf[8:]
|
||||
case 64:
|
||||
tag = uint(bo.Uint64(buf[0:]))
|
||||
val = uint(bo.Uint64(buf[8:]))
|
||||
buf = buf[16:]
|
||||
}
|
||||
switch tag {
|
||||
case _AT_HWCAP:
|
||||
hwcap = val
|
||||
case _AT_HWCAP2:
|
||||
hwcap2 = val
|
||||
}
|
||||
}
|
||||
}
|
||||
if hwcap == 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if hwcap == 0 {
|
||||
// Nothing detected, e.g. on android or a restricted environment.
|
||||
return false
|
||||
}
|
||||
|
||||
// HWCap was populated by the runtime from the auxiliary vector.
|
||||
@@ -184,9 +185,9 @@ func detectOS(c *CPUInfo) bool {
|
||||
c.featureSet.setIf(isSet(hwcap, hwcap_JSCVT), JSCVT)
|
||||
c.featureSet.setIf(isSet(hwcap, hwcap_LRCPC), LRCPC)
|
||||
c.featureSet.setIf(isSet(hwcap, hwcap_PMULL), PMULL)
|
||||
c.featureSet.setIf(isSet(hwcap, hwcap2_RNG), RNDR)
|
||||
// c.featureSet.setIf(isSet(hwcap, hwcap_), TLB)
|
||||
// c.featureSet.setIf(isSet(hwcap, hwcap_), TS)
|
||||
c.featureSet.setIf(isSet(hwcap2, hwcap2_RNG), RNDR)
|
||||
// TLB (FEAT_TLBIOS/TLBIRANGE) has no HWCAP bit; only detectable via ID registers.
|
||||
c.featureSet.setIf(isSet(hwcap, hwcap_FLAGM), TS)
|
||||
c.featureSet.setIf(isSet(hwcap, hwcap_SHA1), SHA1)
|
||||
c.featureSet.setIf(isSet(hwcap, hwcap_SHA2), SHA2)
|
||||
c.featureSet.setIf(isSet(hwcap, hwcap_SHA3), SHA3)
|
||||
@@ -194,6 +195,21 @@ func detectOS(c *CPUInfo) bool {
|
||||
c.featureSet.setIf(isSet(hwcap, hwcap_SM3), SM3)
|
||||
c.featureSet.setIf(isSet(hwcap, hwcap_SM4), SM4)
|
||||
c.featureSet.setIf(isSet(hwcap, hwcap_SVE), SVE)
|
||||
c.featureSet.setIf(isSet(hwcap, hwcap_SB), SB)
|
||||
c.featureSet.setIf(isSet(hwcap, hwcap_SSBS), SSBS)
|
||||
|
||||
// Features reported through the second hardware capability word (HWCAP2).
|
||||
c.featureSet.setIf(isSet(hwcap2, hwcap2_SVE2), SVE2)
|
||||
c.featureSet.setIf(isSet(hwcap2, hwcap2_BTI), BTI)
|
||||
c.featureSet.setIf(isSet(hwcap2, hwcap2_FLAGM2), FLAGM2)
|
||||
c.featureSet.setIf(isSet(hwcap2, hwcap2_FRINT), FRINTTS)
|
||||
c.featureSet.setIf(isSet(hwcap2, hwcap2_DCPODP), DCPODP)
|
||||
c.featureSet.setIf(isSet(hwcap2, hwcap2_BF16), BF16)
|
||||
c.featureSet.setIf(isSet(hwcap2, hwcap2_I8MM), I8MM)
|
||||
c.featureSet.setIf(isSet(hwcap2, hwcap2_WFXT), WFXT)
|
||||
c.featureSet.setIf(isSet(hwcap2, hwcap2_MOPS), MOPS)
|
||||
c.featureSet.setIf(isSet(hwcap2, hwcap2_HBC), HBC)
|
||||
c.featureSet.setIf(isSet(hwcap2, hwcap2_CSSC), CSSC)
|
||||
|
||||
// The Samsung S9+ kernel reports support for atomics, but not all cores
|
||||
// actually support them, resulting in SIGILL. See issue #28431.
|
||||
|
||||
+225
@@ -0,0 +1,225 @@
|
||||
// Copyright (c) 2026 Klaus Post, released under MIT License. See LICENSE file.
|
||||
|
||||
package cpuid
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const __NR_riscv_hwprobe = 258
|
||||
|
||||
type riscvHWProbePair struct {
|
||||
key int64
|
||||
value uint64
|
||||
}
|
||||
|
||||
// Keys from linux/include/uapi/asm/hwprobe.h
|
||||
const (
|
||||
riscv_hwprobe_key_mvendorid = 0
|
||||
riscv_hwprobe_key_marchid = 1
|
||||
riscv_hwprobe_key_mimpid = 2
|
||||
riscv_hwprobe_key_base_behavior = 3
|
||||
riscv_hwprobe_key_ima_ext_0 = 4
|
||||
riscv_hwprobe_key_cpuperf_0 = 5
|
||||
riscv_hwprobe_key_zicbom_block_size = 12
|
||||
)
|
||||
|
||||
// Bits from linux/arch/riscv/include/uapi/asm/hwprobe.h
|
||||
const (
|
||||
riscv_hwprobe_ima_fd = 1 << 0
|
||||
riscv_hwprobe_ima_c = 1 << 1
|
||||
riscv_hwprobe_ima_v = 1 << 2
|
||||
riscv_hwprobe_ext_zba = 1 << 3
|
||||
riscv_hwprobe_ext_zbb = 1 << 4
|
||||
riscv_hwprobe_ext_zbs = 1 << 5
|
||||
riscv_hwprobe_ext_zicboz = 1 << 6
|
||||
riscv_hwprobe_ext_zbc = 1 << 7
|
||||
riscv_hwprobe_ext_zbkb = 1 << 8
|
||||
riscv_hwprobe_ext_zbkc = 1 << 9
|
||||
riscv_hwprobe_ext_zbkx = 1 << 10
|
||||
riscv_hwprobe_ext_zknd = 1 << 11
|
||||
riscv_hwprobe_ext_zkne = 1 << 12
|
||||
riscv_hwprobe_ext_zknh = 1 << 13
|
||||
riscv_hwprobe_ext_zksed = 1 << 14
|
||||
riscv_hwprobe_ext_zksh = 1 << 15
|
||||
riscv_hwprobe_ext_zkt = 1 << 16
|
||||
riscv_hwprobe_ext_zvbb = 1 << 17
|
||||
riscv_hwprobe_ext_zvbc = 1 << 18
|
||||
riscv_hwprobe_ext_zvkb = 1 << 19
|
||||
riscv_hwprobe_ext_zvkg = 1 << 20
|
||||
riscv_hwprobe_ext_zvkned = 1 << 21
|
||||
riscv_hwprobe_ext_zvknha = 1 << 22
|
||||
riscv_hwprobe_ext_zvknhb = 1 << 23
|
||||
riscv_hwprobe_ext_zvksed = 1 << 24
|
||||
riscv_hwprobe_ext_zvksh = 1 << 25
|
||||
riscv_hwprobe_ext_zvkt = 1 << 26
|
||||
riscv_hwprobe_ext_zfh = 1 << 27
|
||||
riscv_hwprobe_ext_zfhmin = 1 << 28
|
||||
riscv_hwprobe_ext_zihintntl = 1 << 29
|
||||
riscv_hwprobe_ext_zvfh = 1 << 30
|
||||
riscv_hwprobe_ext_zvfhmin = 1 << 31
|
||||
riscv_hwprobe_ext_zfa = 1 << 32
|
||||
riscv_hwprobe_ext_ztso = 1 << 33
|
||||
riscv_hwprobe_ext_zacas = 1 << 34
|
||||
riscv_hwprobe_ext_zicond = 1 << 35
|
||||
riscv_hwprobe_ext_zihintpause = 1 << 36
|
||||
riscv_hwprobe_ext_zicbom = 1 << 55
|
||||
riscv_hwprobe_ext_zicbop = 1 << 60
|
||||
)
|
||||
|
||||
func riscvHWProbe(pairs []riscvHWProbePair) int64 {
|
||||
if len(pairs) == 0 {
|
||||
return -1
|
||||
}
|
||||
ret, _, _ := unix.Syscall6(__NR_riscv_hwprobe,
|
||||
uintptr(unsafe.Pointer(&pairs[0])),
|
||||
uintptr(len(pairs)),
|
||||
0, 0, 0, 0)
|
||||
return int64(ret)
|
||||
}
|
||||
|
||||
func detectOS(c *CPUInfo) bool {
|
||||
c.LogicalCores = runtime.NumCPU()
|
||||
c.PhysicalCores = c.LogicalCores
|
||||
c.ThreadsPerCore = 1
|
||||
|
||||
pairs := []riscvHWProbePair{
|
||||
{key: riscv_hwprobe_key_mvendorid},
|
||||
{key: riscv_hwprobe_key_marchid},
|
||||
{key: riscv_hwprobe_key_mimpid},
|
||||
{key: riscv_hwprobe_key_ima_ext_0},
|
||||
{key: riscv_hwprobe_key_zicbom_block_size},
|
||||
}
|
||||
ret := riscvHWProbe(pairs)
|
||||
if ret == 0 && pairs[3].value != ^uint64(0) {
|
||||
detectFromHWProbe(c, pairs)
|
||||
if pairs[4].value != ^uint64(0) && pairs[4].value > 0 {
|
||||
c.CacheLine = int(pairs[4].value)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
c.CacheLine = detectCacheLine()
|
||||
return detectFromCPUInfo(c)
|
||||
}
|
||||
|
||||
func detectFromHWProbe(c *CPUInfo, pairs []riscvHWProbePair) {
|
||||
if pairs[0].value != ^uint64(0) {
|
||||
c.VendorID = riscvVendorID(pairs[0].value)
|
||||
c.VendorString = c.VendorID.String()
|
||||
}
|
||||
if pairs[1].value != ^uint64(0) {
|
||||
c.Model = int(pairs[1].value)
|
||||
}
|
||||
if pairs[2].value != ^uint64(0) {
|
||||
c.Family = int(pairs[2].value)
|
||||
}
|
||||
|
||||
imaExt := pairs[3].value
|
||||
|
||||
if imaExt&riscv_hwprobe_ima_fd != 0 {
|
||||
c.featureSet.set(RV_D)
|
||||
c.featureSet.set(RV_F)
|
||||
}
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ima_c != 0, RV_C)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ima_v != 0, RV_V)
|
||||
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zba != 0, RV_ZBA)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zbb != 0, RV_ZBB)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zbc != 0, RV_ZBC)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zbs != 0, RV_ZBS)
|
||||
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zicbom != 0, RV_ZICBOM)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zicboz != 0, RV_ZICBOZ)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zicbop != 0, RV_ZICBOP)
|
||||
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zicond != 0, RV_ZICOND)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zihintpause != 0, RV_ZIHINTPAUSE)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zfa != 0, RV_ZFA)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zfh != 0, RV_ZFH)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zfhmin != 0, RV_ZFHMIN)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_ztso != 0, RV_ZTSO)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zacas != 0, RV_ZACAS)
|
||||
|
||||
// Scalar cryptography
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zbkb != 0, RV_ZBKB)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zbkc != 0, RV_ZBKC)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zbkx != 0, RV_ZBKX)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zknd != 0, RV_ZKND)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zkne != 0, RV_ZKNE)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zknh != 0, RV_ZKNH)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zksed != 0, RV_ZKSED)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zksh != 0, RV_ZKSH)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zkt != 0, RV_ZKT)
|
||||
|
||||
// Vector cryptography
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvbb != 0, RV_ZVBB)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvbc != 0, RV_ZVBC)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvkb != 0, RV_ZVKB)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvkg != 0, RV_ZVKG)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvkned != 0, RV_ZVKNED)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvknha != 0, RV_ZVKNHA)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvknhb != 0, RV_ZVKNHB)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvksed != 0, RV_ZVKSED)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvksh != 0, RV_ZVKSH)
|
||||
c.featureSet.setIf(imaExt&riscv_hwprobe_ext_zvkt != 0, RV_ZVKT)
|
||||
|
||||
// Crypto suites (combined from individual features)
|
||||
c.featureSet.setIf(c.featureSet.hasSetP(rvZKNFeatures), RV_ZKN)
|
||||
c.featureSet.setIf(c.featureSet.hasSetP(rvZKSFeatures), RV_ZKS)
|
||||
c.featureSet.setIf(c.featureSet.hasSetP(rvZVKNFeatures), RV_ZVKNG)
|
||||
c.featureSet.setIf(c.featureSet.hasSetP(rvZVKSFeatures), RV_ZVKSG)
|
||||
|
||||
// Every Linux-capable riscv64 core has I, M, A base.
|
||||
c.featureSet.set(RV_IMA)
|
||||
}
|
||||
|
||||
func detectFromCPUInfo(c *CPUInfo) bool {
|
||||
f, err := os.Open("/proc/cpuinfo")
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
fields := strings.SplitN(line, ":", 2)
|
||||
if len(fields) < 2 {
|
||||
continue
|
||||
}
|
||||
key := strings.TrimSpace(fields[0])
|
||||
value := strings.TrimSpace(fields[1])
|
||||
|
||||
switch key {
|
||||
case "isa":
|
||||
parseISAString(c, value)
|
||||
case "mvendorid":
|
||||
if vid, err := strconv.ParseUint(value, 0, 64); err == nil {
|
||||
c.VendorID = riscvVendorID(vid)
|
||||
c.VendorString = c.VendorID.String()
|
||||
}
|
||||
case "uarch":
|
||||
c.BrandName = value
|
||||
}
|
||||
}
|
||||
return scanner.Err() == nil
|
||||
}
|
||||
|
||||
func detectCacheLine() int {
|
||||
data, err := os.ReadFile("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size")
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
if n, err := strconv.Atoi(strings.TrimSpace(string(data))); err == nil && n > 0 {
|
||||
return n
|
||||
}
|
||||
return 0
|
||||
}
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2020 Klaus Post, released under MIT License. See LICENSE file.
|
||||
|
||||
//go:build arm64 && !linux && !darwin
|
||||
// +build arm64,!linux,!darwin
|
||||
|
||||
package cpuid
|
||||
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2026 Klaus Post, released under MIT License. See LICENSE file.
|
||||
|
||||
//go:build riscv64 && !linux
|
||||
|
||||
package cpuid
|
||||
|
||||
import "runtime"
|
||||
|
||||
func detectOS(c *CPUInfo) bool {
|
||||
c.PhysicalCores = runtime.NumCPU()
|
||||
c.ThreadsPerCore = 1
|
||||
c.LogicalCores = c.PhysicalCores
|
||||
return false
|
||||
}
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2021 Klaus Post, released under MIT License. See LICENSE file.
|
||||
|
||||
//go:build nounsafe
|
||||
// +build nounsafe
|
||||
|
||||
package cpuid
|
||||
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2021 Klaus Post, released under MIT License. See LICENSE file.
|
||||
|
||||
//go:build !nounsafe
|
||||
// +build !nounsafe
|
||||
|
||||
package cpuid
|
||||
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
// Copyright (c) 2026 Klaus Post, released under MIT License. See LICENSE file.
|
||||
|
||||
package cpuid
|
||||
|
||||
import "strings"
|
||||
|
||||
func parseISAString(c *CPUInfo, isa string) {
|
||||
isa = strings.ToLower(isa)
|
||||
extMap := make(map[string]bool)
|
||||
for ext := range strings.SplitSeq(isa, "_") {
|
||||
ext = strings.TrimSpace(ext)
|
||||
if strings.HasPrefix(ext, "rv64") {
|
||||
extMap["i"] = true
|
||||
for _, ch := range ext[4:] {
|
||||
extMap[string(ch)] = true
|
||||
}
|
||||
} else if ext != "" {
|
||||
extMap[ext] = true
|
||||
}
|
||||
}
|
||||
|
||||
if extMap["g"] {
|
||||
extMap["i"] = true
|
||||
extMap["m"] = true
|
||||
extMap["a"] = true
|
||||
extMap["f"] = true
|
||||
extMap["d"] = true
|
||||
}
|
||||
|
||||
c.featureSet.setIf(extMap["i"] && extMap["m"] && extMap["a"], RV_IMA)
|
||||
c.featureSet.setIf(extMap["c"], RV_C)
|
||||
c.featureSet.setIf(extMap["f"], RV_F)
|
||||
c.featureSet.setIf(extMap["d"], RV_D)
|
||||
c.featureSet.setIf(extMap["v"], RV_V)
|
||||
c.featureSet.setIf(extMap["zihintpause"], RV_ZIHINTPAUSE)
|
||||
c.featureSet.setIf(extMap["zba"], RV_ZBA)
|
||||
c.featureSet.setIf(extMap["zbb"], RV_ZBB)
|
||||
c.featureSet.setIf(extMap["zbc"], RV_ZBC)
|
||||
c.featureSet.setIf(extMap["zbs"], RV_ZBS)
|
||||
c.featureSet.setIf(extMap["zicond"], RV_ZICOND)
|
||||
c.featureSet.setIf(extMap["zicbom"], RV_ZICBOM)
|
||||
c.featureSet.setIf(extMap["zicboz"], RV_ZICBOZ)
|
||||
c.featureSet.setIf(extMap["zicbop"], RV_ZICBOP)
|
||||
c.featureSet.setIf(extMap["zfa"], RV_ZFA)
|
||||
c.featureSet.setIf(extMap["zfh"], RV_ZFH)
|
||||
c.featureSet.setIf(extMap["zfhmin"], RV_ZFHMIN)
|
||||
c.featureSet.setIf(extMap["ztso"], RV_ZTSO)
|
||||
c.featureSet.setIf(extMap["zacas"], RV_ZACAS)
|
||||
|
||||
// Scalar cryptography
|
||||
c.featureSet.setIf(extMap["zbkb"], RV_ZBKB)
|
||||
c.featureSet.setIf(extMap["zbkc"], RV_ZBKC)
|
||||
c.featureSet.setIf(extMap["zbkx"], RV_ZBKX)
|
||||
c.featureSet.setIf(extMap["zknd"], RV_ZKND)
|
||||
c.featureSet.setIf(extMap["zkne"], RV_ZKNE)
|
||||
c.featureSet.setIf(extMap["zknh"], RV_ZKNH)
|
||||
c.featureSet.setIf(extMap["zksed"], RV_ZKSED)
|
||||
c.featureSet.setIf(extMap["zksh"], RV_ZKSH)
|
||||
c.featureSet.setIf(extMap["zkt"], RV_ZKT)
|
||||
|
||||
// Vector cryptography
|
||||
c.featureSet.setIf(extMap["zvbb"], RV_ZVBB)
|
||||
c.featureSet.setIf(extMap["zvbc"], RV_ZVBC)
|
||||
c.featureSet.setIf(extMap["zvkb"], RV_ZVKB)
|
||||
c.featureSet.setIf(extMap["zvkg"], RV_ZVKG)
|
||||
c.featureSet.setIf(extMap["zvkned"], RV_ZVKNED)
|
||||
c.featureSet.setIf(extMap["zvknha"], RV_ZVKNHA)
|
||||
c.featureSet.setIf(extMap["zvknhb"], RV_ZVKNHB)
|
||||
c.featureSet.setIf(extMap["zvksed"], RV_ZVKSED)
|
||||
c.featureSet.setIf(extMap["zvksh"], RV_ZVKSH)
|
||||
c.featureSet.setIf(extMap["zvkt"], RV_ZVKT)
|
||||
|
||||
// Crypto suites (combined from individual features or bundle tokens)
|
||||
c.featureSet.setIf(extMap["zkn"] || c.featureSet.hasSetP(rvZKNFeatures), RV_ZKN)
|
||||
c.featureSet.setIf(extMap["zks"] || c.featureSet.hasSetP(rvZKSFeatures), RV_ZKS)
|
||||
c.featureSet.setIf(extMap["zvkng"] || c.featureSet.hasSetP(rvZVKNFeatures), RV_ZVKNG)
|
||||
c.featureSet.setIf(extMap["zvksg"] || c.featureSet.hasSetP(rvZVKSFeatures), RV_ZVKSG)
|
||||
}
|
||||
|
||||
var riscvVendorMap = map[uint64]Vendor{
|
||||
0x489: SiFive,
|
||||
0x5b7: StarFive,
|
||||
0x5b1: THead,
|
||||
0x31e: Andes,
|
||||
0x710: SpacemiT,
|
||||
}
|
||||
|
||||
func riscvVendorID(mvendorid uint64) Vendor {
|
||||
if v, ok := riscvVendorMap[mvendorid]; ok {
|
||||
return v
|
||||
}
|
||||
return VendorUnknown
|
||||
}
|
||||
Generated
Vendored
+12
-11
@@ -21,17 +21,18 @@ type Config struct {
|
||||
Timeout int64 `mapstructure:"timeout"`
|
||||
Insecure bool `mapstructure:"insecure"`
|
||||
// If true, HTTP COPY will expect the HTTP-TPC (third-party copy) headers
|
||||
EnableHTTPTpc bool `mapstructure:"enable_http_tpc"`
|
||||
PublicURL string `mapstructure:"public_url"`
|
||||
FavoriteStorageDriver string `mapstructure:"favorite_storage_driver"`
|
||||
FavoriteStorageDrivers map[string]map[string]interface{} `mapstructure:"favorite_storage_drivers"`
|
||||
Version string `mapstructure:"version"`
|
||||
VersionString string `mapstructure:"version_string"`
|
||||
Edition string `mapstructure:"edition"`
|
||||
Product string `mapstructure:"product"`
|
||||
ProductName string `mapstructure:"product_name"`
|
||||
ProductVersion string `mapstructure:"product_version"`
|
||||
AllowPropfindDepthInfinitiy bool `mapstructure:"allow_depth_infinity"`
|
||||
EnableHTTPTpc bool `mapstructure:"enable_http_tpc"`
|
||||
PublicURL string `mapstructure:"public_url"`
|
||||
FavoriteStorageDriver string `mapstructure:"favorite_storage_driver"`
|
||||
FavoriteStorageDrivers map[string]map[string]interface{} `mapstructure:"favorite_storage_drivers"`
|
||||
Version string `mapstructure:"version"`
|
||||
VersionString string `mapstructure:"version_string"`
|
||||
Edition string `mapstructure:"edition"`
|
||||
Product string `mapstructure:"product"`
|
||||
ProductName string `mapstructure:"product_name"`
|
||||
ProductVersion string `mapstructure:"product_version"`
|
||||
AllowPropfindDepthInfinitiy bool `mapstructure:"allow_depth_infinity"`
|
||||
DisablePropfindPublicLinkResolution bool `mapstructure:"disable_propfind_public_link_resolution"`
|
||||
|
||||
TransferSharedSecret string `mapstructure:"transfer_shared_secret"`
|
||||
|
||||
|
||||
Generated
Vendored
+55
-35
@@ -22,6 +22,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"encoding/xml"
|
||||
stderr "errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -454,42 +455,9 @@ func (p *Handler) propfindResponse(ctx context.Context, w http.ResponseWriter, r
|
||||
defer span.End()
|
||||
|
||||
var linkshares map[string]struct{}
|
||||
// public link access does not show share-types
|
||||
// oc:share-type is not part of an allprops response
|
||||
if namespace != "/public" {
|
||||
// only fetch this if property was queried
|
||||
for _, prop := range pf.Prop {
|
||||
if prop.Space == net.NsOwncloud && (prop.Local == "share-types" || prop.Local == "permissions") {
|
||||
filters := make([]*link.ListPublicSharesRequest_Filter, 0, len(resourceInfos))
|
||||
for i := range resourceInfos {
|
||||
// FIXME this is expensive
|
||||
// the filters array grow by one for every file in a folder
|
||||
// TODO store public links as grants on the storage, reassembling them here is too costly
|
||||
// we can then add the filter if the file has share-types=3 in the opaque,
|
||||
// same as user / group shares for share indicators
|
||||
filters = append(filters, publicshare.ResourceIDFilter(resourceInfos[i].Id))
|
||||
}
|
||||
client, err := p.selector.Next()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("error getting grpc client")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
listResp, err := client.ListPublicShares(ctx, &link.ListPublicSharesRequest{Filters: filters})
|
||||
if err == nil {
|
||||
linkshares = make(map[string]struct{}, len(listResp.Share))
|
||||
for i := range listResp.Share {
|
||||
linkshares[listResp.Share[i].ResourceId.OpaqueId] = struct{}{}
|
||||
}
|
||||
} else {
|
||||
log.Error().Err(err).Msg("propfindResponse: couldn't list public shares")
|
||||
span.SetStatus(codes.Error, err.Error())
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
if !p.c.DisablePropfindPublicLinkResolution {
|
||||
linkshares = p.resolveLinkshares(ctx, w, namespace, pf, resourceInfos, log)
|
||||
}
|
||||
|
||||
prefer := net.ParsePrefer(r.Header.Get(net.HeaderPrefer))
|
||||
returnMinimal := prefer[net.HeaderPreferReturn] == "minimal"
|
||||
|
||||
@@ -522,6 +490,58 @@ func (p *Handler) propfindResponse(ctx context.Context, w http.ResponseWriter, r
|
||||
}
|
||||
}
|
||||
|
||||
// resolveLinkshares resolves the link shares for the given resource infos
|
||||
func (p *Handler) resolveLinkshares(ctx context.Context, w http.ResponseWriter, namespace string, pf XML, resourceInfos []*provider.ResourceInfo, log zerolog.Logger) map[string]struct{} {
|
||||
ctx, span := appctx.GetTracerProvider(ctx).Tracer(tracerName).Start(ctx, "resolveLinkshares")
|
||||
defer span.End()
|
||||
var linkshares map[string]struct{}
|
||||
// public link access does not show share-types
|
||||
// oc:share-type is not part of an allprops response
|
||||
if namespace != "/public" {
|
||||
localCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
|
||||
defer cancel()
|
||||
// only fetch this if property was queried
|
||||
for _, prop := range pf.Prop {
|
||||
if err := localCtx.Err(); err != nil {
|
||||
if stderr.Is(err, context.DeadlineExceeded) {
|
||||
log.Info().Err(err).Msg("resolveLinkshares: deadline exceeded")
|
||||
span.SetStatus(codes.Error, err.Error())
|
||||
}
|
||||
break
|
||||
}
|
||||
if prop.Space == net.NsOwncloud && (prop.Local == "share-types" || prop.Local == "permissions") {
|
||||
filters := make([]*link.ListPublicSharesRequest_Filter, 0, len(resourceInfos))
|
||||
for i := range resourceInfos {
|
||||
// FIXME this is expensive
|
||||
// the filters array grow by one for every file in a folder
|
||||
// TODO store public links as grants on the storage, reassembling them here is too costly
|
||||
// we can then add the filter if the file has share-types=3 in the opaque,
|
||||
// same as user / group shares for share indicators
|
||||
filters = append(filters, publicshare.ResourceIDFilter(resourceInfos[i].Id))
|
||||
}
|
||||
client, err := p.selector.Next()
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("error getting grpc client")
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return nil
|
||||
}
|
||||
listResp, err := client.ListPublicShares(ctx, &link.ListPublicSharesRequest{Filters: filters})
|
||||
if err == nil {
|
||||
linkshares = make(map[string]struct{}, len(listResp.Share))
|
||||
for i := range listResp.Share {
|
||||
linkshares[listResp.Share[i].ResourceId.OpaqueId] = struct{}{}
|
||||
}
|
||||
} else {
|
||||
log.Error().Err(err).Msg("propfindResponse: couldn't list public shares")
|
||||
span.SetStatus(codes.Error, err.Error())
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
return linkshares
|
||||
}
|
||||
|
||||
// TODO this is just a stat -> rename
|
||||
func (p *Handler) statSpace(ctx context.Context, ref *provider.Reference, metadataKeys, fieldMaskPaths []string) (*provider.ResourceInfo, *rpc.Status, error) {
|
||||
client, err := p.selector.Next()
|
||||
|
||||
+15
-7
@@ -64,13 +64,14 @@ type Options struct {
|
||||
MetricsSubsystem string
|
||||
|
||||
// ocdav.* is internal so we need to set config options individually
|
||||
config config.Config
|
||||
lockSystem ocdav.LockSystem
|
||||
AllowCredentials bool
|
||||
AllowedOrigins []string
|
||||
AllowedHeaders []string
|
||||
AllowedMethods []string
|
||||
AllowDepthInfinity bool
|
||||
config config.Config
|
||||
lockSystem ocdav.LockSystem
|
||||
AllowCredentials bool
|
||||
AllowedOrigins []string
|
||||
AllowedHeaders []string
|
||||
AllowedMethods []string
|
||||
AllowDepthInfinity bool
|
||||
DisablePropfindPublicLinkResolution bool
|
||||
|
||||
RegisterTTL time.Duration
|
||||
RegisterInterval time.Duration
|
||||
@@ -114,6 +115,13 @@ func AllowDepthInfinity(val bool) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// DisablePropfindPublicLinkResolution provides a function to set the DisablePropfindPublicLinkResolution option.
|
||||
func DisablePropfindPublicLinkResolution(val bool) Option {
|
||||
return func(o *Options) {
|
||||
o.DisablePropfindPublicLinkResolution = val
|
||||
}
|
||||
}
|
||||
|
||||
// JWTSecret provides a function to set the jwt secret option.
|
||||
func JWTSecret(s string) Option {
|
||||
return func(o *Options) {
|
||||
|
||||
+5
-4
@@ -22,6 +22,10 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
httpServer "github.com/go-micro/plugins/v4/server/http"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
|
||||
"github.com/owncloud/reva/v2/internal/http/interceptors/appctx"
|
||||
"github.com/owncloud/reva/v2/internal/http/interceptors/auth"
|
||||
cors2 "github.com/owncloud/reva/v2/internal/http/interceptors/cors"
|
||||
@@ -31,10 +35,6 @@ import (
|
||||
"github.com/owncloud/reva/v2/pkg/rhttp/global"
|
||||
"github.com/owncloud/reva/v2/pkg/storage/favorite/memory"
|
||||
rtrace "github.com/owncloud/reva/v2/pkg/trace"
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
httpServer "github.com/go-micro/plugins/v4/server/http"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
@@ -154,6 +154,7 @@ func setDefaults(sopts *Options) error {
|
||||
}
|
||||
|
||||
sopts.config.AllowPropfindDepthInfinitiy = sopts.AllowDepthInfinity
|
||||
sopts.config.DisablePropfindPublicLinkResolution = sopts.DisablePropfindPublicLinkResolution
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
+8
@@ -523,6 +523,14 @@ func (m *manager) ListPublicShares(ctx context.Context, u *user.User, filters []
|
||||
continue
|
||||
}
|
||||
|
||||
if local.ResourceId == nil {
|
||||
log.Warn().
|
||||
Str("share_id", local.PublicShare.GetId().GetOpaqueId()).
|
||||
Str("share_token", local.Token).
|
||||
Msg("ListPublicShares: skipping share with nil resource_id")
|
||||
continue
|
||||
}
|
||||
|
||||
key := strings.Join([]string{local.ResourceId.StorageId, local.ResourceId.OpaqueId}, "!")
|
||||
if _, hit := cache[key]; !hit && !publicshare.IsCreatedByUser(&local.PublicShare, u) {
|
||||
sRes, err := client.Stat(ctx, &provider.StatRequest{Ref: &provider.Reference{ResourceId: local.ResourceId}})
|
||||
|
||||
+4
@@ -87,4 +87,8 @@ type UploadSessionFilter struct {
|
||||
Processing *bool
|
||||
Expired *bool
|
||||
HasVirus *bool
|
||||
// Orphaned filters sessions by whether their target node can still be
|
||||
// resolved. Evaluating it requires reading the node metadata of every
|
||||
// session, so it is only evaluated when set.
|
||||
Orphaned *bool
|
||||
}
|
||||
Generated
Vendored
+6
-1
@@ -296,7 +296,12 @@ func (fs *Decomposedfs) Postprocessing(ch <-chan events.Event) {
|
||||
|
||||
n, err := session.Node(ctx)
|
||||
if err != nil {
|
||||
sublog.Error().Err(err).Msg("could not read node")
|
||||
// The node metadata is unreadable, so this upload can never finish:
|
||||
// the destination cannot be resolved. Clean the session up instead of
|
||||
// leaving it behind to be retried forever. Cleanup falls back to the
|
||||
// session metadata to release the quota.
|
||||
sublog.Error().Err(err).Msg("could not read node, cleaning up orphaned session")
|
||||
session.Cleanup(true, true, true, false)
|
||||
continue
|
||||
}
|
||||
sublog = log.With().Str("spaceid", session.SpaceID()).Str("nodeid", session.NodeID()).Logger()
|
||||
|
||||
+5
@@ -411,6 +411,11 @@ func (fs *Decomposedfs) ListUploadSessions(ctx context.Context, filter storage.U
|
||||
continue
|
||||
}
|
||||
}
|
||||
// evaluated last: unlike the other filters this reads the node metadata
|
||||
// from disk, so it is only done for sessions that passed all other filters
|
||||
if filter.Orphaned != nil && *filter.Orphaned != session.IsOrphaned(ctx) {
|
||||
continue
|
||||
}
|
||||
filteredSessions = append(filteredSessions, session)
|
||||
}
|
||||
return filteredSessions, nil
|
||||
|
||||
Loaded 100 of 173 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user