Skip to content

Commit

Permalink
feat: Argo CD v2.3.5 (argoproj#52)
Browse files Browse the repository at this point in the history
* fix(ui): Applications page incorrectly resets to tiles view. Fixes argoproj#8702 (argoproj#8718)

Signed-off-by: Yuan Tang <terrytangyuan@gmail.com>

* fix: correct jsonnet paths resolution (argoproj#8721)

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>

* chore: Bump stable version of application set addon (argoproj#8744)

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>

* fix: Retry checkbox unchecked unexpectedly; Sync up with YAML (argoproj#8682) (argoproj#8720)

Signed-off-by: Keith Chong <kykchong@redhat.com>

* Bump version to 2.3.1

* Bump version to 2.3.1

* Merge pull request from GHSA-2f5v-8r3f-8pww

* fix: application resource APIs must enforce project restrictions

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>

* Fix unit tests

Signed-off-by: jannfis <jann@mistrust.net>

Co-authored-by: jannfis <jann@mistrust.net>

* chore: remove lint-docs CI task (argoproj#8722) (argoproj#8858)

* chore: remove lint-docs CI task

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>

* chore: remove not longer necessary url-allow-list

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>

Co-authored-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>

* chore: fix imports (argoproj#8859)

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* Bump version to 2.3.2

* Bump version to 2.3.2

* fix: Set QPS and burst rate for resource ops client (argoproj#8915)

* fix: Set QPS and burst rate for resource ops client

Signed-off-by: jannfis <jann@mistrust.net>

* fix: prevent excessive repo-server disk usage for large repos (argoproj#8845) (argoproj#8897)

fix: prevent excessive repo-server disk usage for large repos (argoproj#8845) (argoproj#8897)

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* fix: bump gitops engine version to v0.6.2

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>

* docs: update v2.4+ roadmap items (argoproj#8593)

Signed-off-by: ishitasequeira <isequeir@redhat.com>

* docs: reflect v2.3 release changes in roadmap.md (argoproj#8747)

docs: reflect v2.3 release changes in roadmap.md (argoproj#8747)

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>

* Bump version to 2.3.3

* Bump version to 2.3.3

* fix: Fix docs build error (argoproj#8895)

* work with specific jinja version

Signed-off-by: pashavictorovich <pavel@codefresh.io>

* fix: fix broken monaco editor collapse icons (argoproj#8709)

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>

* chore: upgrade to go 1.17.8 (argoproj#8866) (argoproj#9004)

* chore: upgrade to go 1.17.8

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: use 1.17 so it's always latest in the series

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* fix: allow cli/ui to follow logs (argoproj#8987) (argoproj#9065)

Signed-off-by: Daniel Helfand <helfand.4@gmail.com>

* Merge pull request from GHSA-xmg8-99r8-jc2j

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

Co-authored-by: Michael Crenshaw <michael@crenshaw.dev>

* Merge pull request from GHSA-6gcg-hp2x-q54h

* fix: do not allow symlinks from directory-type applications

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: add new util file

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: lint

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: use t.TempDir for simpler tests

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* address comments

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* Merge pull request from GHSA-r642-gv9p-2wjj

Signed-off-by: jannfis <jann@mistrust.net>

Co-authored-by: Michael Crenshaw <michael@crenshaw.dev>

Co-authored-by: Michael Crenshaw <michael@crenshaw.dev>

* Bump version to 2.3.4

* Bump version to 2.3.4

* test: fix ErrorContains (argoproj#9445)

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* fix: missing Helm params (argoproj#9565) (argoproj#9566)

* fix: missing Helm params

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* use absolute paths, fix tests

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* fix race in test

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: upgrade golangci-lint to v1.46.2 (argoproj#9448)

* chore: upgrade golangci-lint to v1.46.2

Because:

* Installation of golangci-lint v1.45.2 is currently broken and fails
  silently due to a redacted dependency
  (blizzy78/varnamelen#13)

This commit:

* Upgrades golangci-lint to v1.46.2

Signed-off-by: Tommaso Sardelli <lacapannadelloziotom@gmail.com>

* fix: lint

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* fix: lint

Signed-off-by: Tommaso Sardelli <lacapannadelloziotom@gmail.com>

Co-authored-by: Michael Crenshaw <michael@crenshaw.dev>
Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* fix: test race (argoproj#9469)

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: lint issues

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: update golangci-lint (argoproj#8988)

* chore: update golangci-lint

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: remove obsolete repo-server unit test (argoproj#9559)

Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>

* chore: Make unit tests run on platforms other than amd64 (argoproj#8995)

Signed-off-by: jannfis <jann@mistrust.net>

Co-authored-by: Michael Crenshaw <michael@crenshaw.dev>
Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: eliminate go-mpatch dependency (argoproj#9045)

* chore: eliminate go-mpatch dependency

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: abstract out resource list function

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: don't exit the program in anything but the main function

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: better error messages

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: better error messages

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* test: directory app manifest generation (argoproj#9503)

* test: directory app manifest generation

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* git doesn't support empty dirs

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* Merge pull request from GHSA-h4w9-6x78-8vrj

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* Merge pull request from GHSA-2m7h-86qq-fp4v

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

fix references

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

use long enough state param for oauth2

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

typo

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

more entropy

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

fix test

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* Merge pull request from GHSA-q4w5-4gq2-98vm

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* Merge pull request from GHSA-jhqp-vf4w-rpwq

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

defer instead of multiple close calls

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

oops

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

don't count jsonnet against max

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

fix codegen

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

add caveat about 300x ratio

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

fix versions

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

fix tests/lint

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* chore: fix docs gen

Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>

* Bump version to 2.3.5

* Bump version to 2.3.5

* docs: Changes for v2.3.5

Documented key decision factors to use Argo CD v2.3.5.

Contributes to: automation-saas/automation-saas/native-AWS#1972

Signed-off-by: Sujeily Fonseca <sujeily.fonseca@ibm.com>

Co-authored-by: Yuan Tang <terrytangyuan@gmail.com>
Co-authored-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
Co-authored-by: Keith Chong <kykchong@redhat.com>
Co-authored-by: argo-bot <argoproj@gmail.com>
Co-authored-by: jannfis <jann@mistrust.net>
Co-authored-by: Michael Crenshaw <michael@crenshaw.dev>
Co-authored-by: Ishita Sequeira <46771830+ishitasequeira@users.noreply.github.com>
Co-authored-by: pasha-codefresh <pavel@codefresh.io>
Co-authored-by: Daniel Helfand <helfand.4@gmail.com>
Co-authored-by: Tommaso Sardelli <lacapannadelloziotom@gmail.com>
  • Loading branch information
11 people authored and GitHub Enterprise committed Jun 25, 2022
1 parent 32dd8d6 commit 570d9e1
Show file tree
Hide file tree
Showing 100 changed files with 1,922 additions and 449 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci-build.yaml
Expand Up @@ -12,7 +12,7 @@ on:

env:
# Golang version to use across CI steps
GOLANG_VERSION: '1.17.6'
GOLANG_VERSION: '1.17'

jobs:
check-go:
Expand Down Expand Up @@ -61,10 +61,10 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: v1.38.0
args: --timeout 10m --exclude SA5011
version: v1.46.2
args: --timeout 10m --exclude SA5011 --verbose

test-go:
name: Run unit tests for Go packages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/image.yaml
Expand Up @@ -10,7 +10,7 @@ on:
types: [ labeled, unlabeled, opened, synchronize, reopened ]

env:
GOLANG_VERSION: '1.17.6'
GOLANG_VERSION: '1.17'

jobs:
publish:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Expand Up @@ -12,7 +12,7 @@ on:
- '!release-v0*'

env:
GOLANG_VERSION: '1.17.6'
GOLANG_VERSION: '1.17'

jobs:
prepare-release:
Expand Down
22 changes: 0 additions & 22 deletions .golangci.yml

This file was deleted.

36 changes: 32 additions & 4 deletions CHANGES.md
@@ -1,11 +1,39 @@
# ArgoCD
Forked from: [argoproj/argo-cd](https://github.com/argoproj/argo-cd)

## v2.3.3 (Base)
Argo CD's latest stable release, as of May 13, 2022, is v2.3.3.
## v2.4.2 (Base)
Argo CD's latest stable release, as of June 25, 2022, is v2.4.2. The list of Argo CD releases can be accessed [here](https://github.com/argoproj/argo-cd/releases)

## v2.3.5 (Fork)
Argo CD has breaking changes for plugins for v2.4.x:

>Update plugins to use newly-prefixed environment variables
If you use plugins that depend on user-supplied environment variables, then they must be updated to be compatible with Argo CD 2.4. Here is an example of user-supplied environment variables in the plugin section of an Application spec:

```
apiVersion: argoproj.io/v1alpha1
kind: Application
spec:
source:
plugin:
env:
- name: FOO
value: bar
Going forward, all user-supplied environment variables will be prefixed with ARGOCD_ENV_ before being sent to the plugin's init, generate, or discover commands. This prevents users from setting potentially-sensitive environment variables.
```

>If you have written a custom plugin which handles user-provided environment variables, update it to handle the new prefix.
>If you use a third-party plugin which does not explicitly advertise Argo CD 2.4 support, it might not handle the prefixed environment variables. Open an issue with the plugin's authors and confirm support before upgrading to Argo CD 2.4.
The above means that none of the applications will be able to use a user-defined backend service because the Argo CD Vault Plugin currently doesn't provide support to understand the prefixes.

The [release post](https://blog.argoproj.io/breaking-changes-in-argo-cd-2-4-29e3c2ac30c9) mentions the following:

> We'll continue publishing security patches for 2.3.x until 2.6.0 is released.
Because of the above, we proceeded to use v2.3.5, which is the latest 2.3.x version.

## v2.3.3 (Fork)
The changes were rebased based on v2.3.3. This section details the enhancements made to Argo CD Extensions.

### Resource Customization ConfigMap
Pulls in resource overrides from the resource customization `ConfigMap`. This `ConfigMap` will only exist if created by
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Expand Up @@ -4,7 +4,7 @@ ARG BASE_IMAGE=docker.io/library/ubuntu:21.10
# Initial stage which pulls prepares build dependencies and CLI tooling we need for our final image
# Also used as the image in CI jobs so needs all dependencies
####################################################################################################
FROM docker.io/library/golang:1.17.6 as builder
FROM docker.io/library/golang:1.17 as builder

RUN echo 'deb http://deb.debian.org/debian buster-backports main' >> /etc/apt/sources.list

Expand Down Expand Up @@ -102,7 +102,7 @@ RUN HOST_ARCH='amd64' NODE_ENV='production' NODE_ONLINE_ENV='online' NODE_OPTION
####################################################################################################
# Argo CD Build stage which performs the actual build of Argo CD binaries
####################################################################################################
FROM docker.io/library/golang:1.17.6 as argocd-build
FROM docker.io/library/golang:1.17 as argocd-build

WORKDIR /go/src/github.com/argoproj/argo-cd

Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2.3.3
2.3.5
25 changes: 16 additions & 9 deletions cmd/argocd-repo-server/commands/argocd_repo_server.go
Expand Up @@ -13,6 +13,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"google.golang.org/grpc/health/grpc_health_v1"
"k8s.io/apimachinery/pkg/api/resource"

cmdutil "github.com/argoproj/argo-cd/v2/cmd/util"
"github.com/argoproj/argo-cd/v2/common"
Expand Down Expand Up @@ -68,14 +69,15 @@ func getSubmoduleEnabled() bool {

func NewCommand() *cobra.Command {
var (
parallelismLimit int64
listenPort int
metricsPort int
cacheSrc func() (*reposervercache.Cache, error)
tlsConfigCustomizer tls.ConfigCustomizer
tlsConfigCustomizerSrc func() (tls.ConfigCustomizer, error)
redisClient *redis.Client
disableTLS bool
parallelismLimit int64
listenPort int
metricsPort int
cacheSrc func() (*reposervercache.Cache, error)
tlsConfigCustomizer tls.ConfigCustomizer
tlsConfigCustomizerSrc func() (tls.ConfigCustomizer, error)
redisClient *redis.Client
disableTLS bool
maxCombinedDirectoryManifestsSize string
)
var command = cobra.Command{
Use: cliName,
Expand All @@ -95,15 +97,19 @@ func NewCommand() *cobra.Command {
cache, err := cacheSrc()
errors.CheckError(err)

maxCombinedDirectoryManifestsQuantity, err := resource.ParseQuantity(maxCombinedDirectoryManifestsSize)
errors.CheckError(err)

askPassServer := askpass.NewServer()
metricsServer := metrics.NewMetricsServer()
cacheutil.CollectMetrics(redisClient, metricsServer)
server, err := reposerver.NewServer(metricsServer, cache, tlsConfigCustomizer, repository.RepoServerInitConstants{
ParallelismLimit: parallelismLimit,
ParallelismLimit: parallelismLimit,
PauseGenerationAfterFailedGenerationAttempts: getPauseGenerationAfterFailedGenerationAttempts(),
PauseGenerationOnFailureForMinutes: getPauseGenerationOnFailureForMinutes(),
PauseGenerationOnFailureForRequests: getPauseGenerationOnFailureForRequests(),
SubmoduleEnabled: getSubmoduleEnabled(),
MaxCombinedDirectoryManifestsSize: maxCombinedDirectoryManifestsQuantity,
}, askPassServer)
errors.CheckError(err)

Expand Down Expand Up @@ -168,6 +174,7 @@ func NewCommand() *cobra.Command {
command.Flags().IntVar(&listenPort, "port", common.DefaultPortRepoServer, "Listen on given port for incoming connections")
command.Flags().IntVar(&metricsPort, "metrics-port", common.DefaultPortRepoServerMetrics, "Start metrics server on given port")
command.Flags().BoolVar(&disableTLS, "disable-tls", env.ParseBoolFromEnv("ARGOCD_REPO_SERVER_DISABLE_TLS", false), "Disable TLS on the gRPC endpoint")
command.Flags().StringVar(&maxCombinedDirectoryManifestsSize, "max-combined-directory-manifests-size", env.StringFromEnv("ARGOCD_REPO_SERVER_MAX_COMBINED_DIRECTORY_MANIFESTS_SIZE", "10M"), "Max combined size of manifest files in a directory-type Application")

tlsConfigCustomizerSrc = tls.AddTLSFlagsToCmd(&command)
cacheSrc = reposervercache.AddCacheFlagsToCmd(&command, func(client *redis.Client) {
Expand Down
45 changes: 32 additions & 13 deletions cmd/argocd/commands/admin/project_allowlist.go
Expand Up @@ -2,6 +2,7 @@ package admin

import (
"bufio"
"fmt"
"io"
"io/ioutil"
"os"
Expand Down Expand Up @@ -63,7 +64,10 @@ func NewProjectAllowListGenCommand() *cobra.Command {
}()
}

globalProj := generateProjectAllowList(clientConfig, clusterRoleFileName, projName)
resourceList, err := getResourceList(clientConfig)
errors.CheckError(err)
globalProj, err := generateProjectAllowList(resourceList, clusterRoleFileName, projName)
errors.CheckError(err)

yamlBytes, err := yaml.Marshal(globalProj)
errors.CheckError(err)
Expand All @@ -78,23 +82,38 @@ func NewProjectAllowListGenCommand() *cobra.Command {
return command
}

func generateProjectAllowList(clientConfig clientcmd.ClientConfig, clusterRoleFileName string, projName string) v1alpha1.AppProject {
func getResourceList(clientConfig clientcmd.ClientConfig) ([]*metav1.APIResourceList, error) {
config, err := clientConfig.ClientConfig()
if err != nil {
return nil, fmt.Errorf("error while creating client config: %s", err)
}
disco, err := discovery.NewDiscoveryClientForConfig(config)
if err != nil {
return nil, fmt.Errorf("error while creating discovery client: %s", err)
}
serverResources, err := disco.ServerPreferredResources()
if err != nil {
return nil, fmt.Errorf("error while getting server resources: %s", err)
}
return serverResources, nil
}

func generateProjectAllowList(serverResources []*metav1.APIResourceList, clusterRoleFileName string, projName string) (*v1alpha1.AppProject, error) {
yamlBytes, err := ioutil.ReadFile(clusterRoleFileName)
errors.CheckError(err)
if err != nil {
return nil, fmt.Errorf("error reading cluster role file: %s", err)
}
var obj unstructured.Unstructured
err = yaml.Unmarshal(yamlBytes, &obj)
errors.CheckError(err)
if err != nil {
return nil, fmt.Errorf("error unmarshalling cluster role file yaml: %s", err)
}

clusterRole := &rbacv1.ClusterRole{}
err = scheme.Scheme.Convert(&obj, clusterRole, nil)
errors.CheckError(err)

config, err := clientConfig.ClientConfig()
errors.CheckError(err)
disco, err := discovery.NewDiscoveryClientForConfig(config)
errors.CheckError(err)
serverResources, err := disco.ServerPreferredResources()
errors.CheckError(err)
if err != nil {
return nil, fmt.Errorf("error converting cluster role yaml into ClusterRole struct: %s", err)
}

resourceList := make([]metav1.GroupKind, 0)
for _, rule := range clusterRole.Rules {
Expand Down Expand Up @@ -140,5 +159,5 @@ func generateProjectAllowList(clientConfig clientcmd.ClientConfig, clusterRoleFi
Spec: v1alpha1.AppProjectSpec{},
}
globalProj.Spec.NamespaceResourceWhitelist = resourceList
return globalProj
return &globalProj, nil
}
49 changes: 6 additions & 43 deletions cmd/argocd/commands/admin/project_allowlist_test.go
@@ -1,57 +1,20 @@
package admin

import (
"reflect"
"testing"

"github.com/stretchr/testify/assert"
"github.com/undefinedlabs/go-mpatch"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/discovery"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)

func TestProjectAllowListGen(t *testing.T) {
useMock := true
rules := clientcmd.NewDefaultClientConfigLoadingRules()
overrides := &clientcmd.ConfigOverrides{}
clientConfig := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(rules, overrides)

if useMock {
var patchClientConfig *mpatch.Patch
patchClientConfig, err := mpatch.PatchInstanceMethodByName(reflect.TypeOf(clientConfig), "ClientConfig", func(*clientcmd.DeferredLoadingClientConfig) (*restclient.Config, error) {
return nil, nil
})
assert.NoError(t, err)

patch, err := mpatch.PatchMethod(discovery.NewDiscoveryClientForConfig, func(c *restclient.Config) (*discovery.DiscoveryClient, error) {
return &discovery.DiscoveryClient{LegacyPrefix: "/api"}, nil
})
assert.NoError(t, err)

var patchSeverPreferredResources *mpatch.Patch
discoClient := &discovery.DiscoveryClient{}
patchSeverPreferredResources, err = mpatch.PatchInstanceMethodByName(reflect.TypeOf(discoClient), "ServerPreferredResources", func(*discovery.DiscoveryClient) ([]*metav1.APIResourceList, error) {
res := metav1.APIResource{
Name: "services",
Kind: "Service",
}
resourceList := []*metav1.APIResourceList{{APIResources: []metav1.APIResource{res}}}
return resourceList, nil
})
assert.NoError(t, err)

defer func() {
err = patchClientConfig.Unpatch()
assert.NoError(t, err)
err = patch.Unpatch()
assert.NoError(t, err)
err = patchSeverPreferredResources.Unpatch()
err = patch.Unpatch()
}()
res := metav1.APIResource{
Name: "services",
Kind: "Service",
}
resourceList := []*metav1.APIResourceList{{APIResources: []metav1.APIResource{res}}}

globalProj := generateProjectAllowList(clientConfig, "testdata/test_clusterrole.yaml", "testproj")
globalProj, err := generateProjectAllowList(resourceList, "testdata/test_clusterrole.yaml", "testproj")
assert.NoError(t, err)
assert.True(t, len(globalProj.Spec.NamespaceResourceWhitelist) > 0)
}
3 changes: 2 additions & 1 deletion cmd/argocd/commands/app.go
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/spf13/cobra"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -776,7 +777,7 @@ func getLocalObjectsString(app *argoappv1.Application, local, localRepoRoot, app
ApiVersions: apiVersions,
Plugins: configManagementPlugins,
TrackingMethod: trackingMethod,
}, true, &git.NoopCredsStore{})
}, true, &git.NoopCredsStore{}, resource.MustParse("0"))
errors.CheckError(err)

return res.Manifests
Expand Down
11 changes: 8 additions & 3 deletions cmd/argocd/commands/login.go
Expand Up @@ -200,7 +200,10 @@ func oauth2Login(ctx context.Context, port int, oidcSettings *settingspkg.OIDCCo
// completionChan is to signal flow completed. Non-empty string indicates error
completionChan := make(chan string)
// stateNonce is an OAuth2 state nonce
stateNonce := rand.RandString(10)
// According to the spec (https://www.rfc-editor.org/rfc/rfc6749#section-10.10), this must be guessable with
// probability <= 2^(-128). The following call generates one of 52^24 random strings, ~= 2^136 possibilities.
stateNonce, err := rand.String(24)
errors.CheckError(err)
var tokenString string
var refreshToken string

Expand All @@ -210,7 +213,8 @@ func oauth2Login(ctx context.Context, port int, oidcSettings *settingspkg.OIDCCo
}

// PKCE implementation of https://tools.ietf.org/html/rfc7636
codeVerifier := rand.RandStringCharset(43, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~")
codeVerifier, err := rand.StringFromCharset(43, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~")
errors.CheckError(err)
codeChallengeHash := sha256.Sum256([]byte(codeVerifier))
codeChallenge := base64.RawURLEncoding.EncodeToString(codeChallengeHash[:])

Expand Down Expand Up @@ -294,7 +298,8 @@ func oauth2Login(ctx context.Context, port int, oidcSettings *settingspkg.OIDCCo
opts = append(opts, oauth2.SetAuthURLParam("code_challenge_method", "S256"))
url = oauth2conf.AuthCodeURL(stateNonce, opts...)
case oidcutil.GrantTypeImplicit:
url = oidcutil.ImplicitFlowURL(oauth2conf, stateNonce, opts...)
url, err = oidcutil.ImplicitFlowURL(oauth2conf, stateNonce, opts...)
errors.CheckError(err)
default:
log.Fatalf("Unsupported grant type: %v", grantType)
}
Expand Down
8 changes: 7 additions & 1 deletion controller/sync.go
Expand Up @@ -140,7 +140,13 @@ func (m *appStateManager) SyncAppState(app *v1alpha1.Application, state *v1alpha
}

atomic.AddUint64(&syncIdPrefix, 1)
syncId := fmt.Sprintf("%05d-%s", syncIdPrefix, rand.RandString(5))
randSuffix, err := rand.String(5)
if err != nil {
state.Phase = common.OperationError
state.Message = fmt.Sprintf("Failed generate random sync ID: %v", err)
return
}
syncId := fmt.Sprintf("%05d-%s", syncIdPrefix, randSuffix)

logEntry := log.WithFields(log.Fields{"application": app.Name, "syncId": syncId})
initialResourcesRes := make([]common.ResourceSyncResult, 0)
Expand Down

0 comments on commit 570d9e1

Please sign in to comment.