This commit is contained in:
Fuhui Peng (c) 2017-08-18 16:16:52 +08:00
commit e4af0bdb10
6 changed files with 24 additions and 12 deletions

View File

@ -50,7 +50,7 @@ Copy the `vulnerability.sql` and `clear.sql` to the host where Harbor is running
```
$ docker exec -i clair-db psql -U postgres < clear.sql
$ docker exec -i clair-db psql U postgres < vulnerability.sql
$ docker exec -i clair-db psql -U postgres < vulnerability.sql
```
### Rescanning images

View File

@ -43,7 +43,7 @@ create table user (
# The mark of deleted user is "#user_id".
# The 11 consist of 10 for the max value of user_id(4294967295)
# in MySQL and 1 of '#'.
username varchar(32),
username varchar(255),
# 11 bytes is reserved for marking the deleted users.
email varchar(255),
password varchar(40) NOT NULL,
@ -99,7 +99,7 @@ insert into project_member (project_id, user_id, role, creation_time, update_tim
create table access_log (
log_id int NOT NULL AUTO_INCREMENT,
username varchar (32) NOT NULL,
username varchar (255) NOT NULL,
project_id int NOT NULL,
repo_name varchar (256),
repo_tag varchar (128),
@ -142,7 +142,7 @@ create table replication_target (
id int NOT NULL AUTO_INCREMENT,
name varchar(64),
url varchar(64),
username varchar(40),
username varchar(255),
password varchar(128),
/*
target_type indicates the type of target registry,

View File

@ -38,7 +38,7 @@ create table user (
The 11 consist of 10 for the max value of user_id(4294967295)
in MySQL and 1 of '#'.
*/
username varchar(32),
username varchar(255),
/*
11 bytes is reserved for marking the deleted users.
*/
@ -96,7 +96,7 @@ insert into project_member (project_id, user_id, role, creation_time, update_tim
create table access_log (
log_id INTEGER PRIMARY KEY,
username varchar (32) NOT NULL,
username varchar (255) NOT NULL,
project_id int NOT NULL,
repo_name varchar (256),
repo_tag varchar (128),
@ -137,7 +137,7 @@ create table replication_target (
id INTEGER PRIMARY KEY,
name varchar(64),
url varchar(64),
username varchar(40),
username varchar(255),
password varchar(128),
/*
target_type indicates the type of target registry,

View File

@ -22,6 +22,12 @@ import (
// AddAccessLog persists the access logs
func AddAccessLog(accessLog models.AccessLog) error {
// the max length of username in database is 255, replace the last
// three charaters with "..." if the length is greater than 256
if len(accessLog.Username) > 255 {
accessLog.Username = accessLog.Username[:252] + "..."
}
o := GetOrmer()
_, err := o.Insert(&accessLog)
return err

View File

@ -12,8 +12,8 @@ class User(Base):
__tablename__ = 'user'
user_id = sa.Column(sa.Integer, primary_key=True)
username = sa.Column(sa.String(15), unique=True)
email = sa.Column(sa.String(30), unique=True)
username = sa.Column(sa.String(255), unique=True)
email = sa.Column(sa.String(255), unique=True)
password = sa.Column(sa.String(40), nullable=False)
realname = sa.Column(sa.String(255), nullable=False)
comment = sa.Column(sa.String(30))
@ -106,7 +106,7 @@ class ReplicationTarget(Base):
id = sa.Column(sa.Integer, primary_key=True)
name = sa.Column(sa.String(64))
url = sa.Column(sa.String(64))
username = sa.Column(sa.String(40))
username = sa.Column(sa.String(255))
password = sa.Column(sa.String(40))
target_type = sa.Column(mysql.TINYINT(1), nullable=False, server_default=sa.text("'0'"))
creation_time = sa.Column(mysql.TIMESTAMP, server_default = sa.text("CURRENT_TIMESTAMP"))
@ -144,7 +144,7 @@ class AccessLog(Base):
user_id = sa.Column(sa.Integer, nullable=False)
log_id = sa.Column(sa.Integer, primary_key=True)
username = sa.Column(sa.String(32), nullable=False)
username = sa.Column(sa.String(255), nullable=False)
project_id = sa.Column(sa.Integer, nullable=False)
repo_name = sa.Column(sa.String(256))
repo_tag = sa.Column(sa.String(128))

View File

@ -46,7 +46,7 @@ def upgrade():
op.drop_constraint('access_log_ibfk_2', 'access_log', type_='foreignkey')
#add colume username to access_log
op.add_column('access_log', sa.Column('username', mysql.VARCHAR(32), nullable=False))
op.add_column('access_log', sa.Column('username', mysql.VARCHAR(255), nullable=False))
#init username
session.query(AccessLog).update({AccessLog.username: ""})
@ -56,6 +56,12 @@ def upgrade():
for user in user_all:
session.query(AccessLog).filter(AccessLog.user_id == user.user_id).update({AccessLog.username: user.username}, synchronize_session='fetch')
#update user.username length to 255
op.alter_column('user', 'username', type_=sa.String(255), existing_type=sa.String(32))
#update replication_target.username length to 255
op.alter_column('replication_target', 'username', type_=sa.String(255), existing_type=sa.String(40))
op.drop_column("access_log", "user_id")
op.drop_column("repository", "owner_id")