Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e
Submodule e updated from b37a41 to 254b78
3 changes: 0 additions & 3 deletions fuzz/oss-fuzz-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ build_teleport_fuzzers() {
compile_native_go_fuzzer $TELEPORT_PREFIX/lib/services \
FuzzParserEvalBoolPredicate fuzz_parser_eval_bool_predicate

compile_native_go_fuzzer $TELEPORT_PREFIX/lib/auth \
FuzzParseSAMLInResponseTo fuzz_parse_saml_in_response_to

compile_native_go_fuzzer $TELEPORT_PREFIX/lib/restrictedsession \
FuzzParseIPSpec fuzz_parse_ip_spec

Expand Down
7 changes: 0 additions & 7 deletions lib/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,6 @@ func NewServer(cfg *InitConfig, opts ...ServerOption) (*Server, error) {
)
}
}
// Plug in SAML auth service
sas := NewSAMLAuthService(&SAMLAuthServiceConfig{
Auth: &as,
Emitter: as.emitter,
AssertionReplayService: as.Unstable.AssertionReplayService,
})
as.SetSAMLService(sas)

return &as, nil
}
Expand Down
176 changes: 0 additions & 176 deletions lib/auth/auth_with_roles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import (
"github.com/gravitational/teleport/lib/auth/testauthority"
libdefaults "github.com/gravitational/teleport/lib/defaults"
"github.com/gravitational/teleport/lib/events"
"github.com/gravitational/teleport/lib/fixtures"
"github.com/gravitational/teleport/lib/services"
"github.com/gravitational/teleport/lib/session"
"github.com/gravitational/teleport/lib/tlsca"
Expand Down Expand Up @@ -156,181 +155,6 @@ func TestSSOUserCanReissueCert(t *testing.T) {
require.NoError(t, err)
}

func TestSAMLAuthRequest(t *testing.T) {
ctx := context.Background()
srv := newTestTLSServer(t)

emptyRole, err := CreateRole(ctx, srv.Auth(), "test-empty", types.RoleSpecV5{})
require.NoError(t, err)

_, err = CreateRole(ctx, srv.Auth(), "baz", types.RoleSpecV5{})
require.NoError(t, err)

access1Role, err := CreateRole(ctx, srv.Auth(), "test-access-1", types.RoleSpecV5{
Allow: types.RoleConditions{
Rules: []types.Rule{
{
Resources: []string{types.KindSAMLRequest},
Verbs: []string{types.VerbCreate},
},
},
},
})
require.NoError(t, err)

access2Role, err := CreateRole(ctx, srv.Auth(), "test-access-2", types.RoleSpecV5{
Allow: types.RoleConditions{
Rules: []types.Rule{
{
Resources: []string{types.KindSAML},
Verbs: []string{types.VerbCreate},
},
},
},
})
require.NoError(t, err)

access3Role, err := CreateRole(ctx, srv.Auth(), "test-access-3", types.RoleSpecV5{
Allow: types.RoleConditions{
Rules: []types.Rule{
{
Resources: []string{types.KindSAML, types.KindSAMLRequest},
Verbs: []string{types.VerbCreate},
},
},
},
})
require.NoError(t, err)

readerRole, err := CreateRole(ctx, srv.Auth(), "test-access-4", types.RoleSpecV5{
Allow: types.RoleConditions{
Rules: []types.Rule{
{
Resources: []string{types.KindSAMLRequest},
Verbs: []string{types.VerbRead},
},
},
},
})
require.NoError(t, err)

conn, err := types.NewSAMLConnector("foo", types.SAMLConnectorSpecV2{
Issuer: "test",
SSO: "test",
Cert: fixtures.TLSCACertPEM,
AssertionConsumerService: "test",
AttributesToRoles: []types.AttributeMapping{{
Name: "foo",
Value: "bar",
Roles: []string{"baz"},
}},
})
require.NoError(t, err)

err = srv.Auth().UpsertSAMLConnector(ctx, conn)
require.NoError(t, err)

reqNormal := types.SAMLAuthRequest{ConnectorID: conn.GetName(), Type: constants.SAML}
reqTest := types.SAMLAuthRequest{ConnectorID: conn.GetName(), Type: constants.SAML, SSOTestFlow: true, ConnectorSpec: &types.SAMLConnectorSpecV2{
Issuer: "test",
Audience: "test",
ServiceProviderIssuer: "test",
SSO: "test",
Cert: fixtures.TLSCACertPEM,
AssertionConsumerService: "test",
AttributesToRoles: []types.AttributeMapping{{
Name: "foo",
Value: "bar",
Roles: []string{"baz"},
}},
}}

tests := []struct {
desc string
roles []string
request types.SAMLAuthRequest
expectAccessDenied bool
}{
{
desc: "empty role - no access",
roles: []string{emptyRole.GetName()},
request: reqNormal,
expectAccessDenied: true,
},
{
desc: "can create regular request with normal access",
roles: []string{access1Role.GetName()},
request: reqNormal,
expectAccessDenied: false,
},
{
desc: "cannot create sso test request with normal access",
roles: []string{access1Role.GetName()},
request: reqTest,
expectAccessDenied: true,
},
{
desc: "cannot create normal request with connector access",
roles: []string{access2Role.GetName()},
request: reqNormal,
expectAccessDenied: true,
},
{
desc: "cannot create sso test request with connector access",
roles: []string{access2Role.GetName()},
request: reqTest,
expectAccessDenied: true,
},
{
desc: "can create regular request with combined access",
roles: []string{access3Role.GetName()},
request: reqNormal,
expectAccessDenied: false,
},
{
desc: "can create sso test request with combined access",
roles: []string{access3Role.GetName()},
request: reqTest,
expectAccessDenied: false,
},
}

user, err := CreateUser(srv.Auth(), "dummy")
require.NoError(t, err)

userReader, err := CreateUser(srv.Auth(), "dummy-reader", readerRole)
require.NoError(t, err)

clientReader, err := srv.NewClient(TestUser(userReader.GetName()))
require.NoError(t, err)

for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
user.SetRoles(tt.roles)
err = srv.Auth().UpsertUser(user)
require.NoError(t, err)

client, err := srv.NewClient(TestUser(user.GetName()))
require.NoError(t, err)

request, err := client.CreateSAMLAuthRequest(ctx, tt.request)
if tt.expectAccessDenied {
require.Error(t, err)
require.True(t, trace.IsAccessDenied(err), "expected access denied, got: %v", err)
return
}

require.NoError(t, err)
require.NotEmpty(t, request.ID)
require.Equal(t, tt.request.ConnectorID, request.ConnectorID)

requestCopy, err := clientReader.GetSAMLAuthRequest(ctx, request.ID)
require.NoError(t, err)
require.Equal(t, request, requestCopy)
})
}
}

func TestInstaller(t *testing.T) {
ctx := context.Background()
srv := newTestTLSServer(t)
Expand Down
13 changes: 0 additions & 13 deletions lib/auth/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,11 @@ limitations under the License.
package auth

import (
"encoding/base64"
"testing"

"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
)

func FuzzParseSAMLInResponseTo(f *testing.F) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with this part of the codebase, but are we okay with removing this fuzz test completely? From what I see, it wasn't moved to teleport.e.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reference to this test can be also found in

FuzzParseSAMLInResponseTo fuzz_parse_saml_in_response_to

So probably we need to remove it from there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes. I over-zealously removed this (the always-failing CIFuzz annoys me no end), and forgot to see what I needed to do to move it to the new repo. I'll get onto that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oss-fuzz-build.sh fixed in 340df18

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the fuzz test to the enterprise PR. As yet there is nothing to run it as there is no CI job there to do fuzz testing. I can't figure out how the fuzz/oss-fuzz-build.sh script is meant to work - I think I'm missing the context in which it runs - there look to be undefined functions and variables, so I suspect OSSFuzz provides this context and corpora. A similar setup will need to be done on the enterprise repo.

@reedloden Is there any feedback you can add?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OSS-Fuzz runs fuzz/oss-fuzz-build.sh from the config in https://github.com/google/oss-fuzz/tree/master/projects/teleport.

OSS-Fuzz only works on open source projects. We can use https://fuzzbuzz.io/ for teleport.e, but it's not configured yet. As long as you ensure Go-native fuzzing is set up (by way of the fuzz test existing), when we do get Fuzzbuzz working, it will Just Work(TM).

// Disable Go App Engine logging
logrus.SetLevel(logrus.PanicLevel)

f.Fuzz(func(t *testing.T, response string) {
require.NotPanics(t, func() {
ParseSAMLInResponseTo(base64.StdEncoding.EncodeToString([]byte(response)))
})
})
}

func FuzzParseAndVerifyIID(f *testing.F) {
f.Fuzz(func(t *testing.T, iidBytes []byte) {
require.NotPanics(t, func() {
Expand Down
Loading